2

I am using Linux Mint Nadia and have both Python 3.2.3 and Python 2.7.3 installed. I access each using IDLE and have some modules that only work on 1 version. I think the default version is 2.7.3 because this is what appears when I type "python" in the terminal.

I am trying to install scipy for python3. Despite following all the instructions on the scipy webpage, including downloading and unpacking it, making sure I have dependencies, and finally using

python setup.py install

I received an error regarding BLAS, which another person experienced: Does Python SciPy need BLAS?

I installed setuptools and tried to use easy_install as well as followed the 34 positive vote answer on the above link, which did not work either, and finally used the 21 vote instruction

apt-get install python-scipy

which finally worked, but installed it for python 2.7.3. I need to use scipy on python3 and believe that the easiest way for me to do this would be to change the default python on my linux and then re-run apt-get install python-scipy. I also think that this will make installing future modules on python 3 easier, as I mainly use python 3.

What is the right way to change the default installation or should I do something differently in order to be able to use scipy on python3 and make it easier to install future modules? I have also noticed that other modules install by default on python 2.7.3.

Community
  • 1
  • 1
user2144412
  • 123
  • 1
  • 9
  • 4
    [Virtualenv](http://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv) to the resque! – alko Jan 14 '14 at 20:05
  • I don't have too much need for python2.7, wouldn't it be easier to change the default version on my system? Otherwise I found this link which I can use to understand what virtualenv is, how to use it, and how to install packages on it: http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ – user2144412 Jan 14 '14 at 20:13
  • You're best using virtualenv. It's a minor pain in the butt to use something outside your Linux package manager, but Linux distributions are always a bit behind. Another alternative is to see if your Linux distribution includes an installer for pip, and then use pip to install Python modules. If you're trying to use Python modules that only work with Python 1, though, I'd seriously suggest finding better Python modules. Python 1 is incredibly old and almost nothing useful exists for it specifically. – Jim Stewart Jan 14 '14 at 20:17
  • @JimStewart I guess "on 1 version" means "works on 2.7 or 3.2 but not on both" – alko Jan 14 '14 at 20:32

1 Answers1

3

It's not a good idea to try to change the default Python version installed by the OS because several system scripts may depend on the specific version.

Most Linux distros have Python 2.7.x and 3.3.x in their repositories. If you need another version, download the source, build it, and move the build to /opt. Then use virtualenv (and virtualenvwrapper) to select the Python version for each specific project.

$ cd myproject
$ mkvirtualenv -p /opt/python2.5/bin/python myproject
$ workon myproject
$ setvirtualenvproject

virtualenv will install pip for you, so you can install the desired modules, even to specific versions.

Both virtualenv and virtualenvwrapper are available in the repositories of Debian-based distros, like Mint.

Apalala
  • 9,017
  • 3
  • 30
  • 48
  • I wasn't sure exactly what you meant by 'build it and move the build to opt'. When I did `./configure` and `make`, there wasn't actually a Python executable in the `build` subdirectory. What worked for me was to type `./configure --prefix=/opt/python-2.7.9`, `make` and `sudo make install`, and then `mkvirtualenv -p /opt/python-2.7.9/bin/python2.7 myproject`. Some 'bits' were missing, though, so I had to mess with the `PYTHONPATH`... I assume there's a cleaner way? – Michael Scheper Nov 11 '15 at 02:21
  • Actually, I redid it after installing -dev packages in my OS for the 'bits' that were missing, e.g. `sudo apt-get install lib64readline6-dev` for readline. I'm still hoping for a less cumbersome way, but this was definitely cleaner. – Michael Scheper Nov 13 '15 at 02:35