【问题标题】:Manage python packages in Sublime text 3在 Sublime text 3 中管理 python 包
【发布时间】:2015-07-14 07:30:40
【问题描述】:

使用 Ubuntu 14.04

如何告诉 Sublime text 3 和 SublimeREPL 在哪里寻找 python 包?

从我的终端,pip list 返回一个包含许多类似 Python 包的列表:

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)

但是,在 Sublime text 3 中,在控制台上:

>>> 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'

从 SulbimeREPL 控制台:

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'

所以,我认为需要设置一些东西。

【问题讨论】:

  • import sys; sys.executable 的输出是什么?
  • 你在使用 virtualenv 吗?如果是这样,其可执行文件的路径是什么?
  • @Railslide 不,我没有使用 virtualenv,我在 virtualBox 上使用 Ubuntu。 @Anand,sublime text 3 控制台中的输出为:python3,SublimeREPL 控制台中的输出为:/usr/bin/python3.3
  • pip --version 的输出是什么?
  • @Railslide,pip --version 的输出在我的终端中给了我:pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)

标签: python sublimetext3 packages sublimerepl


【解决方案1】:

您需要将 SublimeRepl 指向正确的解释器。

添加到Settings -&gt; Package Settings -&gt; SublimeREPL -&gt; Settings - User

{
    "default_extend_env": {"PATH": "{PATH}:/usr/lib/python2.7"}
}

【讨论】:

    【解决方案2】:

    试试这个

    python3 -m pip install --user openpyxl
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-09
      • 2019-04-15
      • 1970-01-01
      • 2016-02-07
      • 1970-01-01
      • 1970-01-01
      • 2016-02-08
      相关资源
      最近更新 更多