使用turtlebot3_machine_learning包跑DQN算法BUG记

  1. 运行roslaunch turtlebot3_dqn result_graph.launch时遇到如下问题:
Exception: PyQtGraph requires one of PyQt4, PyQt5 or PySide; none of these packages could be imported.
Traceback (most recent call last):
  File "/home/xy/turtle3_ws/src/turtlebot3_machine_learning/turtlebot3_dqn/nodes/action_graph", line 21, in <module>
    from PyQt5.QtWidgets import *
ImportError: No module named PyQt5.QtWidgets
[result_graph-2] process has died [pid 1654, exit code 1, cmd /home/xy/turtle3_ws/src/turtlebot3_machine_learning/turtlebot3_dqn/nodes/result_graph __name:=result_graph __log:=/home/xy/.ros/log/7140455c-9918-11ea-a408-e86a642b9771/result_graph-2.log].
log file: /home/xy/.ros/log/7140455c-9918-11ea-a408-e86a642b9771/result_graph-2*.log
[action_graph-3] process has died [pid 1666, exit code 1, cmd /home/xy/turtle3_ws/src/turtlebot3_machine_learning/turtlebot3_dqn/nodes/action_graph __name:=action_graph __log:=/home/xy/.ros/log/7140455c-9918-11ea-a408-e86a642b9771/action_graph-3.log].
log file: /home/xy/.ros/log/7140455c-9918-11ea-a408-e86a642b9771/action_graph-3*.log
  1. 此种情况是因为在anaconda3下建立的虚拟环境装的深度学习环境,故会出现以上问题。可以通过在系统中共存一个anaconda2环境来解决。对anaconda2和anaconda3能同时存在一个系统中,可以通过将其中一个安装到另一个的环境文件夹env中,由于本文前期安装了anaconda3,故现将anaconda2做为其环境安装在anaconda3的env文件夹中。
  2. 清华镜像下载相应2版本的anaconda,然后在终端执行以下命令:
nuc@xy:~$ bash Anaconda2-5.2.0-Linux-x86_64.sh -b -p /home/xy/anaconda3/envs/anapy2    #anapy2为所创建的虚拟环境名

一路安装完成:

installing: numba-0.38.0-py27h637b7d7_0 ...
installing: numexpr-2.6.5-py27h7bf3b9c_0 ...
installing: pandas-0.23.0-py27h637b7d7_0 ...
installing: pywavelets-0.5.2-py27hecda097_0 ...
installing: scipy-1.1.0-py27hfc37229_0 ...
installing: bkcharts-0.2-py27h241ae91_0 ...
installing: dask-0.17.5-py27_0 ...
installing: patsy-0.5.0-py27_0 ...
installing: pytables-3.4.3-py27h02b9ad4_2 ...
installing: scikit-learn-0.19.1-py27h445a80a_0 ...
installing: odo-0.5.1-py27h9170de3_0 ...
installing: scikit-image-0.13.1-py27h14c3975_1 ...
installing: statsmodels-0.9.0-py27h3010b51_0 ...
installing: blaze-0.11.3-py27h5f341da_0 ...
installing: seaborn-0.8.1-py27h633ea1e_0 ...
installing: anaconda-5.2.0-py27_3 ...
installation finished.
WARNING:
    You currently have a PYTHONPATH environment variable set. This may cause
    unexpected behavior when running the Python interpreter in Anaconda2.
    For best results, please verify that your PYTHONPATH only points to
    directories of packages that are compatible with the Python interpreter
    in Anaconda2: /home/xy/anaconda3/envs/anapy2

然后,激活该虚拟环境,显示为Python 2.7.15 |Anaconda, Inc.:

nuc@xy:~$ source activate anapy2
(anapy2) nuc@xy:~$ python
Python 2.7.15 |Anaconda, Inc.| (default, May  1 2018, 23:32:55) 
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

此时退出该该虚拟环境,并验证python显示为Python 3.6.5 |Anaconda, Inc.:

(anapy2) nuc@xy:~$ source deactivate   #退出anapy2虚拟环境
nuc@xy:~$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

以上说明anaconda2和anaconda3已经成功共存于系统,接下来在anapy2环境中重新安装深度学习环境,跑源代码即可。

猜你喜欢

转载自blog.csdn.net/qq_42091428/article/details/106203820