I have a problem with Linux in PC. I installed python3.8. I want work with python 3. When I create a virtualenv file it gets created with python2, but I don't want work with python2. How can I enable python2?
Asked
Active
Viewed 1.1k times
0
-
can you post the code you're using to create the virtualenv? – Kelvin Dec 20 '19 at 15:31
-
1Type **python3** instead of **python** while executing commands. – dannyxn Dec 20 '19 at 15:31
-
1Does this answer your question? [Using Python 3 in virtualenv](https://stackoverflow.com/questions/23842713/using-python-3-in-virtualenv) – D Malan Dec 20 '19 at 15:31
-
virtualenv file name – Dec 20 '19 at 15:33
-
Is there a typo in "How can I enable python2?", you do _not_ want to run any python2 in this venv. You want a python3.x interpreter – AlanSE Dec 20 '19 at 15:38
2 Answers
5
You can set a python version while creating a new virtual environment using the -p
flag.
virtualenv -p python3.8 my-env-name

Shuvojit
- 1,390
- 8
- 16
0
Perhaps you can try to locate the location of the python version you want to use the interpreter of (eg. get its path through which python3
). Once obtained the path you can create the enviroment specifying the location of the interpreter you want to use for that virtual environment virtualenv -p /usr/bin/python3.6 venv

Federico Taranto
- 132
- 5