I have some project that needs python 3.4 but since I am on Ubuntu 18.04 I have python 3.6 installed. If I try to setup the project on 3.6 I get compatibility issues. Please guide how do I install python 3.4 alongside 3.6. And is there a way to make virtualenv use python 3.4 to setup environments.
1 Answer
By compile the binary:
Download the zip package of python3.4 from here
extract it and enter in the folder
- execute:
./configure
- execute:
make -j 4
If you have more core insert the number of core of your cpu - execute:
make test -j 4
same as above, OPTIONAL but suggested! - execute:
sudo make install
If you find the binary package you can skip the compilation steps.
Install virtualenv:
sudo apt install virtualenv
then create a virtual environment with desired python version:
virtualenv --python=python3.4 --clear --always-copy --setuptools .venv
virtualenv .venv --distribute
note: .venv
is the path where virtual environment is installed
Alternative to a virtual environment you can use the python executable directly from path you choose, but I recommend you to use a virtual environment, keep your system more clean.
to activate the virtual environment execute the bash script perform following steps:
source .venv/bin/activate
to exit from the virtualenv
exit
will close the terminal and the virtualenv.
You can also configure mostly of IDE to use the python virtual env.