Manage python packages in Sublime text 3

2019-08-12 04:17发布

Working with Ubuntu 14.04

How to tell Sublime text 3 and SublimeREPL where to look for the python packages?

From my terminal, pip list returns a list with many python packages like that:

numexpr (2.2.2)
numpy (1.8.2)
oauthlib (0.6.1)
oneconf (0.3.7)
openpyxl (2.2.5)
PAM (0.4.2)
pandas (0.16.2)

However, inside Sublime text 3, on the console:

>>> import openpyxl
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'openpyxl'

>>> import pandas
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'pandas'

>>> import numpy
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'numpy'

From the SulbimeREPL console:

Python 3.3.6 (default, Jan 28 2015, 17:27:09) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'pandas'
>>> import openpyxl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'openpyxl'

So, I assume that something needs to be set up.

1条回答
淡お忘
2楼-- · 2019-08-12 04:55

You need to point SublimeRepl to the right interpreter.

Add to Settings -> Package Settings -> SublimeREPL -> Settings - User

{
    "default_extend_env": {"PATH": "{PATH}:/usr/lib/python2.7"}
}
查看更多
登录 后发表回答