简体   繁体   English

使用Enthought Python而不是系统Python

[英]Using Enthought Python instead of the system Python

I've installed the Enthought Python Distribution , which is basically a glorified Python distribution with added libraries for numerical and scientific computing. 我已经安装了Enthought Python Distribution ,它基本上是一个美化的Python发行版,增加了用于数值和科学计算的库。 Now, since I use Debian, there is Python installed already. 现在,因为我使用Debian,所以已经安装了Python。 If I wish to use the Enthought Python for all work, how would I go about doing that? 如果我希望将Enthought Python用于所有工作,我将如何去做呢?

Right now I am using a rudimentary alias like: 现在我正在使用一个基本的别名,如:

alias python='/usr/local/share/enthought/bin/python'

This is fine, but fails for shebang directives like #! /usr/bin/env python 这很好,但是对#shebang指令失败了#! /usr/bin/env python #! /usr/bin/env python in independent Python scripts. #! /usr/bin/env python在独立的Python脚本中。 So how do I get the system to use Enthought Python (without breaking anything of course!). 那么如何让系统使用Enthought Python(当然不会破坏任何东西!)。 Thanks! 谢谢!

I think this is the official way of doing it, as recommended by Enthought: 根据Enthought的建议,我认为这是正式的做法:

export PATH=/usr/local/EPD/bin:$PATH

if you installed to /usr/local/EPD . 如果你安装到/usr/local/EPD Otherwise, the general form is 否则,一般形式是

export PATH=/path/to/EPD/bin:$PATH 

This prepends the path to the EPD binary directory to your system PATH variable. 这会将EPD二进制目录的路径添加到系统PATH变量中。 The : is some sort of concatenate symbol. :是某种连接符号。 You can either run this in terminal every time, or you can put this in your ~/.bashrc file. 您可以每次在终端中运行它,也可以将它放在〜/ .bashrc文件中。


Critical Edit: 关键编辑:

It turns out that EPD should actually be appended to the PATH, or you may have OS problems. 事实证明,EPD实际上应该附加到PATH,否则您可能会遇到操作系统问题。 Do it like this: 像这样做:

 export PATH=$PATH:/path/to/EPD/bin

If your on Debian you could install enthought Python in virtualenv . 如果你在Debian上你可以在virtualenv中安装enthought Python。

Enthought would have its own libraries without bothering other debian programs that need the system version. Enthought将拥有自己的库,而不会打扰需要系统版本的其他debian程序。 You could make switching easier between environments with virtualenvwrapper . 您可以使用virtualenvwrapper在环境之间轻松切换。

There is also a method with virtualenv to share (certain) site-packages among environments. 还有一种使用virtualenv在环境之间共享(某些)站点包的方法。 Make sure to use pip instead of easy_install within a virtualenv. 确保在virtualenv中使用pip而不是easy_install。

Django people do it all the time. Django人一直这样做。

将当前版本的python符号链接到Enthought。

ln -s /usr/bin/python[version]  /path/to/enthought/python

I think, that on Debian it is better to install packages like this: 我想,在Debian上最好安装这样的软件包:

apt-get install python-numpy python-numpy-doc python-scipy python-matplotlib ipython

instead of install Enthought Python Distribution. 而不是安装Enthought Python Distribution。

Hmm I'm also encountering this problem. 嗯,我也遇到了这个问题。 The first thing I did was the suggestion to prepend python to the path as suggested by Chad, but this results in some problems for other linux apps that use libraries that are not included in Enthought but are included in Linux Mint (or whatever distro you're using). 我做的第一件事就是根据Chad的建议将python添加到路径中的建议,但是这会导致其他Linux应用程序出现一些问题,这些应用程序使用未包含在Enthought中但未包含在Linux Mint(或任何发行版中)的库中。重新使用)。 In particular, if I load python from terminal, I successfully enter Enthought's version of python, but running "import pygtk" results in an error (because the library isn't installed in the Enthought version of python). 特别是,如果我从终端加载python,我成功输入了Enthought的python版本,但运行“import pygtk”会导致错误(因为库没有安装在python的Enthought版本中)。

Does anyone know how to use PYTHONPATH to include first Enthought libraries, and then include the standard Linux libraries? 有谁知道如何使用PYTHONPATH包含第一个Enthought库,然后包含标准的Linux库? This would be the optimal configuration.... 这将是最佳配置....

I use aliases. 我使用别名。

alias python=~/Softwares/EPD_7.3/epd-7.3-2-rh5-x86_64/bin/python
alias ipython=~/Softwares/EPD_7.3/epd-7.3-2-rh5-x86_64/bin/ipython

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

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