转载网址:
https://www.ncnynl.com/archives/201611/1056.html
http://blog.csdn.net/ynb19930428/article/details/79028807
从官网下载免费版的pycharm
$ tar xfz pycharm-community-2017.3.4 #解压
$ cd pycharm-community-2017.3.4
$ ./pycharm.sh #按提示安装即可
配置pycharm
- 设置快捷键,使从快捷方式启动PyCharm的同时加载ROS环境变量
gedit ~/.local/share/applications/jetbrains-pycharm.desktop #如果选择安装为当前用户可用
或者
gedit /usr/share/applications/jetbrains-pycharm.desktop #如果选择为全部用户可用
[Desktop Entry] Version=1.0 Type=Application Name=PyCharm Icon=/home/jxl/pycharm-community-2017.3.4/bin/pycharm.png Exec= bash -i -c "/home/jxl/pycharm-community-2017.3.4/bin/pycharm.sh" %f Comment=The Drive to Develop Categories=Development;IDE;
Terminal=false StartupWMClass=jetbrains-pycharm
- 修改Exec变量一行,在=后添加 bash -i -c 即改为
Exec= bash -i -c "/home/jxl/pycharm-community-2017.3.4/bin/pycharm.sh" %f
- 保存并退出。
- 添加 bash -i -c 是为了在通过快捷方式启动PyCharm的同时加载ROS环境变量(ROS环境变量加载脚本配置在 ~/.bashrc 文件内)
- 注意:文件中的 Icon 和Exec 行的路经是自己的安装包位置,每个人不一样。
设置python2.7为PyCharm工程的Interpreter
PyCharm默认将Python 3.2设置为工程的interpreter,而ROS使用的是Python 2.7,这里需要设置一下,使用Python 2.7,否则无法运行ROS相关的Python库。如果默认是Python 2.7则不用修改。
File 菜单 -> Settings 项,打开设置对话框,选择 Project Interpreter -> Python Interpreters 如下图:
加载rospy 相关库
pycharm
1.打开File–>Settings–>Project:XXXX–>Project Interpreter
2.在Project Interpreter : Python 2.7 /usr/bin/python (顶部的位置)点击下拉箭头
3.选择Show ALL…
4.点击右侧第5个按钮:interpreter Paths
/opt/ros/indigo/lib/python2.7/dist-packages
- 1
6.一路ok就可以了
7.然后运行一下,成功!