简体   繁体   English

热情的python无法识别系统模块

[英]Enthought python not recognising system modules

I have installed the Enthought Python Distribution (ie python 2.7) on a Ubuntu 12.04 virtual machine and it would be very useful if it could recognise modules imported via the synaptic package manager. 我已经在Ubuntu 12.04虚拟机上安装了Enthought Python发行版(即python 2.7),如果它可以识别通过突触包管理器导入的模块,这将非常有用。 Currently, these are only recognised by the system-provided python installation (quite understandably). 目前,这些仅由系统提供的python安装识别(完全可以理解)。 Since both pythons are 2.7, is it possible to make my EPD installation recognise the system modules? 由于两个python均为2.7,是否可以使我的EPD安装识别系统模块? Thanks. 谢谢。

No, using synaptic-installed modules with EPD is not supported. 不可以,不支持将突触安装的模块与EPD一起使用。 Of course, you can try adding specific packages to your PYTHONPATH, but this is likely to create conflicts, especially for modules containing C-extensions that may be linked against a slightly different version of Python. 当然,您可以尝试将特定的程序包添加到PYTHONPATH中,但这可能会产生冲突,尤其是对于包含C扩展名且可能与稍有不同的Python版本链接的模块。

Currently, the recommended way to install python packages in EPD is with the enpkg tool. 当前,推荐的方法是使用enpkg工具在EPD中安装python软件包。 Try enpkg -s <packagename> to see if your desired package is in Enthought's repository. 尝试enpkg -s <packagename>来查看所需的软件包是否在Enthought的存储库中。 If you haven't already, you should upgrade enpkg itself by running enpkg enstaller and enter your EPD credentials by running enpkg --userpass . 如果你还没有准备好,你应该通过运行升级enpkg本身enpkg enstaller并通过运行输入您的EPD凭据enpkg --userpass Then you should be able to install supported packages with enpkg <packagename> (Using enpkg to update EPD packages) . 然后,您应该能够使用enpkg <packagename>安装受支持的软件包(使用enpkg更新EPD软件包)

If the package you're looking for isn't in Enthought's repository, you can install pip with enpkg pip and install packages in EPD with that tool. 如果您要查找的软件包不在Enthought的存储库中,则可以使用enpkg pip安装enpkg pip并使用该工具将其安装在EPD中。

Alternately, you can download the source for your desired package and install it with python setup.py install , assuming the package has a setup.py. 或者,您可以下载所需软件包的源代码,并使用python setup.py install (假设软件包具有setup.py)。

Note: if you install a package into EPD without using enpkg, you should make sure to remove the EPD version of the package first if it exists ( enpkg --remove <packagename> ). 注意:如果在不使用enpkg的情况下将软件包安装到EPD中,则应确保先删除该软件包的EPD版本(如果存在)( enpkg --remove <packagename> )。 If you later choose to install the package with enpkg, you should first remove the version you installed with an alternate method (Using non-EPD package installers such as pip) . 如果以后选择使用enpkg安装软件包,则应首先使用其他方法(使用非EPD软件包安装程序,如pip)删除安装的版本。

There is also an upcoming GUI package manager from Enthought, currently in Beta. Enthought即将推出一个GUI软件包管理器,目前处于Beta版。

Had the same problem.Enthought distribution uses completely different python paths and library prefix than your run of the mill system distribution. 遇到了同样的问题。思想的发行版使用的python路径和库前缀与运行mill系统的发行版完全不同。 So if you use pip, pip will install on your system path, not your EPD path. 因此,如果您使用pip,则pip将安装在系统路径上,而不是EPD路径上。 Solution: 解:

1) get your EPD prefix with: enpkg --path 1)使用以下命令获取EPD前缀: enpkg --path

2) write it down somewhere 2)在某处写下

3) if you pip install then type: 3)如果您通过pip安装,请输入:

pip install --install-option="--prefix=$PREFIX_PATH" package_name

as written by Ian Bicking on Install a Python package into a different directory using pip? 如Ian Bicking在使用pip将Python软件包安装到其他目​​录中所述? .

The previous answer might be obsolete. 先前的答案可能已过时。 On version 4.6.3 use enpkg --env to get the prefix 在版本4.6.3上,使用enpkg --env获取前缀

$ enpkg --version
enstaller version: 4.6.3

$ enpkg --env

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM