使用turtlebot3_machine_learning包跑DQN算法BUG记
- 运行roslaunch turtlebot3_dqn result_graph.launch时遇到如下问题:
1 Exception: PyQtGraph requires one of PyQt4, PyQt5 or PySide; none of these packages could be imported. 2 Traceback (most recent call last): 3 File "/home/xy/turtle3_ws/src/turtlebot3_machine_learning/turtlebot3_dqn/nodes/action_graph", line 21, in <module> 4 from PyQt5.QtWidgets import * 5 ImportError: No module named PyQt5.QtWidgets 6 [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]. 7 log file: /home/xy/.ros/log/7140455c-9918-11ea-a408-e86a642b9771/result_graph-2*.log 8 [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]. 9 log file: /home/xy/.ros/log/7140455c-9918-11ea-a408-e86a642b9771/action_graph-3*.log
- 此种情况是因为在anaconda3下建立的虚拟环境装的深度学习环境,故会出现以上问题。可以通过在系统中共存一个anaconda2环境来解决。对anaconda2和anaconda3能同时存在一个系统中,可以通过将其中一个安装到另一个的环境文件夹env中,由于本文前期安装了anaconda3,故现将anaconda2做为其环境安装在anaconda3的env文件夹中。
- 到清华镜像下载相应2版本的anaconda,然后在终端执行以下命令:
1 nuc@xy:~$ bash Anaconda2-5.2.0-Linux-x86_64.sh -b -p /home/xy/anaconda3/envs/anapy2 #anapy2为所创建的虚拟环境名
一路安装完成:
1 installing: numba-0.38.0-py27h637b7d7_0 ... 2 installing: numexpr-2.6.5-py27h7bf3b9c_0 ... 3 installing: pandas-0.23.0-py27h637b7d7_0 ... 4 installing: pywavelets-0.5.2-py27hecda097_0 ... 5 installing: scipy-1.1.0-py27hfc37229_0 ... 6 installing: bkcharts-0.2-py27h241ae91_0 ... 7 installing: dask-0.17.5-py27_0 ... 8 installing: patsy-0.5.0-py27_0 ... 9 installing: pytables-3.4.3-py27h02b9ad4_2 ... 10 installing: scikit-learn-0.19.1-py27h445a80a_0 ... 11 installing: odo-0.5.1-py27h9170de3_0 ... 12 installing: scikit-image-0.13.1-py27h14c3975_1 ... 13 installing: statsmodels-0.9.0-py27h3010b51_0 ... 14 installing: blaze-0.11.3-py27h5f341da_0 ... 15 installing: seaborn-0.8.1-py27h633ea1e_0 ... 16 installing: anaconda-5.2.0-py27_3 ... 17 installation finished. 18 WARNING: 19 You currently have a PYTHONPATH environment variable set. This may cause 20 unexpected behavior when running the Python interpreter in Anaconda2. 21 For best results, please verify that your PYTHONPATH only points to 22 directories of packages that are compatible with the Python interpreter 23 in Anaconda2: /home/xy/anaconda3/envs/anapy2
然后,激活该虚拟环境,显示为Python 2.7.15 |Anaconda, Inc.:
1 nuc@xy:~$ source activate anapy2 2 (anapy2) nuc@xy:~$ python 3 Python 2.7.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55) 4 [GCC 7.2.0] on linux2 5 Type "help", "copyright", "credits" or "license" for more information. 6 >>>
此时退出该该虚拟环境,并验证python显示为Python 3.6.5 |Anaconda, Inc.:
1 (anapy2) nuc@xy:~$ source deactivate #退出anapy2虚拟环境 2 nuc@xy:~$ python 3 Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 4 [GCC 7.2.0] on linux 5 Type "help", "copyright", "credits" or "license" for more information. 6 >>>
以上说明anaconda2和anaconda3已经成功共存于系统,接下来在anapy2环境中重新安装深度学习环境,跑源代码即可。