Based on python requirment you can first instal python version you want. Just time of virtual environment creation mention python version. Below have provided example with python3.7. if you want to use create python3.8 or any other version, replace python3.7 with your python version.
- Create python virtual environment without pip
$ python3.7 -m venv myenv_python37 --without-pip
- Activate python virtual environment you created above
$ source myenv_python37/bin/activate
- Now, install pip inside virtual environment
$ curl https://bootstrap.pypa.io/get-pip.py | python
If you get error while installing pip:
ModuleNotFoundError: No module named 'distutils.cmd'
install below distutils package
$ sudo apt-get install python3.7-distutils
Install all requirement for python 3.7 inside virtual enviornment
$ pip install -r requirements.txt
- After your work is done, close virtual environment
Note:
- This helps maintaining multiple python and pip version on one system and using python and its supported package based on your requirement.
- All packages from requirements.txt would be accesible inside virtual environment only, not global on your system for python3.7
Top comments (0)