(For reprinting, please specify the author and source: https://yangningbocn.github.io is not used for commercial purposes without permission)


Notebook model: Lenovo Y500

CPU : Intel® Core™ i7-3630QM CPU @ 2.40GHz × 8

Memory: 7.7 GiB

Video card: GeForce GT 750M/PCIe/SSE2

System version: Ubuntu 14.04 LTS 64bit

Software: sublime text 3; pycharm

Error situation

import rospy
ImportError: No module named rospy

Problem description

It is impossible to import rospy and other modules under pycharm and sublime, but it can run normally with the command line under Terminal. After analysis, the reason is that the path under / opt / ROS / indigo / lib / Python 2.7 / dist-packages has not been added to the environment.


sublime text 3

1. cd/opt/sublime_text/Packages under Terminal
2.sudo gedit Python.sublime-package
3. paste

    "shell_cmd": "python -u \"$file\"",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",

    "env": {"PYTHONPATH":"/opt/ros/indigo/lib/python2.7/dist-packages"},

            "name": "Syntax Check",
            "shell_cmd": "python -m py_compile \"${file}\"",

4. Save and Exit
5. Next, delete the Python. sublime-build file in C++. sublime-package with the zip command: sudo zip-d Python. sublime-package Python. sublime-build
6. Finally, add the previous Python. sublime-build to Python. sublime-package at this time: sudo zip-g Python. sublime-package Python. sublime-build

  1. Restart sublime text, experiment calls the default Python build system, successful!


1. Open File – > Settings – > Project: XXXX – > Project Interpreter
2. In Project Interpreter: Python 2.7/usr/bin/python (top position) click the drop-down arrow
3. Select Show ALL…
4. Click the fourth button on the right: interpreter Paths
5. Click the first plus button on the right and paste the following path in the pop-up dialog box


6. Ok all the way.
7. Then run it and succeed!

Feelings of Sublime and pycharm

Sublime is just too light and fast. It has a great user experience, but it’s not powerful enough.
Pycharm has many functions, such as looking at the library. But sometimes Kaka’s.