Ray
Ray

Reputation: 8563

`virtualenv` with Python 3.5 on Ubuntu 15.04

I've never used virtualenv, I'm working on Ubuntu 15.04 (remotely via ssh), and I've been told I can't make any changes to system the Pythons. Ubuntu 15.04 comes with Pythons 2.7 and 3.4.3, but I want Python 3.5 in my virtualenv. I've tried virtualenv -p python3.5 my_env and it gives The executable python3.5 (from --python=python3.5) does not exist, which I take to mean that it's complaining about the system not having Python 3.5. So, is it impossible to create a virtualenv with Python 3.5, if the system does not already have Python 3.5?

Upvotes: 2

Views: 935

Answers (1)

OmPS
OmPS

Reputation: 341

You can just install the latest version of python. You can also download and install the different versions in your user's home dir.

In case you are planning to have multiple versions installed manually. This is from the offical python README file.

Installing multiple versions

On Unix and Mac systems if you intend to install multiple versions of Python using the same installation prefix (--prefix argument to the configure script) you must take care that your primary python executable is not overwritten by the installation of a different version. All files and directories installed using "make altinstall" contain the major and minor version and can thus live side-by-side. "make install" also creates ${prefix}/bin/python3 which refers to ${prefix}/bin/pythonX.Y. If you intend to install multiple versions using the same prefix you must decide which version (if any) is your "primary" version. Install that version using "make install". Install all other versions using "make altinstall".

For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute "make install" in your 2.6 build directory and "make altinstall" in the others.

Once done that you can continue using the virtual environment for python using the python version of your choice.

Upvotes: 2

Related Questions