Using Enthought Python instead of the system Python
Asked Answered
S

6

9

I've installed the Enthought Python Distribution, which is basically a glorified Python distribution with added libraries for numerical and scientific computing. Now, since I use Debian, there is Python installed already. If I wish to use the Enthought Python for all work, how would I go about doing that?

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 in independent Python scripts. So how do I get the system to use Enthought Python (without breaking anything of course!). Thanks!

Stratocumulus answered 25/1, 2012 at 19:16 Comment(0)
A
12

I think this is the official way of doing it, as recommended by Enthought:

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

if you installed to /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. 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.


Critical Edit:

It turns out that EPD should actually be appended to the PATH, or you may have OS problems. Do it like this:

 export PATH=$PATH:/path/to/EPD/bin
Abut answered 14/6, 2012 at 18:47 Comment(0)
H
5

If your on Debian you could install enthought Python in virtualenv.

Enthought would have its own libraries without bothering other debian programs that need the system version. You could make switching easier between environments with virtualenvwrapper.

There is also a method with virtualenv to share (certain) site-packages among environments. Make sure to use pip instead of easy_install within a virtualenv.

Django people do it all the time.

Huckaby answered 25/1, 2012 at 22:0 Comment(2)
This is the right way to do it. It doesn't break standard commands and the infrastructure of your computer, and it allows you to easily use the EPD when desired by just doing so from within the virtualenv.Amenra
how do you install enthoughts in a virtualenv? I can't find any documentation that walks through this process. Any help would be appreciated. Thank you.Sweeping
F
2

Symlink the current version of python to the Enthought one.

ln -s /usr/bin/python[version]  /path/to/enthought/python
Fia answered 25/1, 2012 at 19:20 Comment(5)
Uhm, after some tests, this does not seem to work. Symlinking breaks many other programs. For example, I can't import the gtk module now. Must have to do something with the PYTHONPATH.Stratocumulus
@Stratocumulus - You can't import gtk because it's not installed. If you want to use it for your EPD install, then you'll need to install gtk using the enthought python build. Often, (especially for things like gtk which link to compiled libraries) this means recompiling from source. Just changing your PYTHONPATH generally won't work, as your system's python is often a completely different version. If you're working with libraries that are C-extensions, and they're built against a different version of python, things won't work.Rebeca
@JoeKington Good advice. And it looks like its better if I don't meddle with the system Python.Stratocumulus
@Stratocumulus I'm always wary when modifying to an outside python distribution vs installing the libraries that they use on my own for this very reason.Fia
Well, you can certainly install new things on top of EPD. Just be sure to build them with EPD's python. (And link them against EPD's libraries, etc.) It's not too hard to do, but you do need to be aware of where things are and be reasonably familiar with configuring and building things from source. In most cases, just either a) use EPD's easy_install, or b) if you're directly compiling a project (like gtk) be sure that it detects the proper python binary (which in most cases means that it will detect the proper headers/libraries for that python).Rebeca
B
2

I think, that on Debian it is better to install packages like this:

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

instead of install Enthought Python Distribution.

Bargain answered 10/2, 2012 at 7:58 Comment(1)
Yeah, I did try that first. But the packages in the Debian repositories are cripplingly outdated. For my purpose I require the latest version of matplotlib which isn't there in the repos. Thanks anyway.Stratocumulus
I
1

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). 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).

Does anyone know how to use PYTHONPATH to include first Enthought libraries, and then include the standard Linux libraries? This would be the optimal configuration....

Instillation answered 3/1, 2013 at 5:22 Comment(2)
See my edit above. The path should actually be appended to rather than prepended to.Abut
Also, to answer your question, put export PYTHONPATH=$PYTHONPATH:/path/to/standard/libraries in your ~/.bashrcAbut
K
0

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
Kaete answered 31/5, 2013 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.