Manage python packages in Sublime text 3

安稳与你 提交于 2019-12-24 13:11:42

问题


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:


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"}
}


来源:https://stackoverflow.com/questions/31400372/manage-python-packages-in-sublime-text-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!