Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Virtual environment using python 3.8 when python 2.7 is present

I am trying to create a virtual environment using mkvirtualenv with python 3 in Windows but the environment is created with python 2.7.My pip version is also from python 2.7 which i have avoided using

py -m pip install virtualenvwrapper-win

When i do

mkvirtualenv test

environment is created with python 2.7 Please help me with a solution Thanks in advance:)

like image 520
AVA Avatar asked May 20 '20 08:05

AVA


People also ask

How to create a virtual environment in Python?

When creating virtual environment, a pyvenv.cfg is created that has home key which tells where the python executable is, which was used to create the virtual environment. If your global python installation is version 3.8.6, and you run

Is it possible to run Python 2 7 on venv?

If Python 2.7 is not on your PATH as python, use full path to the python executable in place of python. Then, you can create virtual environments that have Python 2.7 with * It is not supported by the venv module out of the box, at least.

What's the difference between pyvenv and virtualenv?

Unlike the old virtualenv tool, pyvenv doesn’t support creating environments with arbitrary versions of Python, which means you’re stuck using the default Python 3 installation for all of the environments you create.

What does it mean when ENV is currently active in Python?

This is the indicator that env is currently active, which means the python executable will only use this environment’s packages and settings. To show the package isolation in action, we can use the bcrypt module as an example. Let’s say we have bcrypt installed system-wide but not in our virtual environment.


Video Answer


2 Answers

If you would like to create a virtualenv with python 3.X having the version 2.X

You just have to pass a parameter argument for your virtual env.

$ virtualenv venv -p $(which python3)

This command will point to your current python3 install folder, and create a virtualenv copied from your current python3 binaries.

If you would like to see what this command does, just fire the command:

$ which python3
#should print your current python3 binary folder.
like image 162
Danizavtz Avatar answered Nov 08 '22 16:11

Danizavtz


you need install python3.8 to your enviroment, if you are in ubuntu(18.04):

sudo apt install python3.8

and:

mkvirtualenv name_of_the_project -p python3.8
like image 30
José Augusto Avatar answered Nov 08 '22 17:11

José Augusto