Virtualenv & Switching Versions
Last updated
Last updated
If you are having issue using tools that require diferent python version then this i for you
Taken from .
Installation
This module does not come built-in with Python. To install this type the below command in the terminal.
Syntax:
If we want to change all files in the currently open folder and all the files in the subfolder from Python2 to Python3 type the below command.
If we want to change a particular file in the current folder from Python2 to Python3 then enter the following command.
env
First install python2
Create a virtual environment for a project:
virtualenv venv
will create a folder in the current directory which will contain the Python executable files, and a copy of the pip
library which you can use to install other packages. The name of the virtual environment (in this case, it was venv
) can be anything; omitting the name will place the files in the current directory instead.
This creates a copy of Python in whichever directory you ran the command in, placing it in a folder named venv
.
You can also use the Python interpreter of your choice (like python2.7
).
or change the interpreter globally with an env variable in ~/.bashrc
:
To begin using the virtual environment, it needs to be activated:
Install packages using the pip command:
This puts you back to the system’s default Python interpreter with all its installed libraries.
To delete a virtual environment, just delete its folder. (In this case, it would be rm -rf venv.)