Problems creating virtual env with different Python version
NickName:Schelmuffsky Ask DateTime:2020-01-30T21:56:02

Problems creating virtual env with different Python version

I'm working on a big project that needs to be ported from python2.7 to python3.7. For developing, I rely on virtual envs.

For the 2.7v, I'm using a virtual environment created with the virtualenv module and it's packages virtualenvwrapper, and virtualenvwrapper-win.

For the 3.7v, I tried to create an env by using the same packages, this time I installed them to the python3.7 directory. I managed to set up the python3.7 with its own environmental variable, naming it python3.exe so I could chose, where to install additional python packages.

i.e. pip install virtualenv - to install Virtualenv in the python2.7 directory, but

python3 -m pip install virtualenv - to install it into the python3.7 directory

C:\Users\user1>pip freeze
...
stevedore==1.30.1
virtualenv==16.4.3
virtualenv-clone==0.5.1
virtualenvwrapper==4.8.4
virtualenvwrapper-win==1.2.5

vs.

C:\Users\user1>python3 -m pip freeze
...
stevedore==1.31.0
virtualenv==16.7.5
virtualenv-clone==0.5.3
virtualenvwrapper==4.8.4
virtualenvwrapper-win==1.2.5

So far so good.

When I want to create a virtual env named envTest with python3.7, here's the command I use:

mkvirtualenv python3 envTest

To avoid any further misidentification, I renamed the new python executable in the local env's folder to python0.exe.

Now, I can check the paths and versions of all three available python sources (python.exe=python2.7 , python3.exe=python3.7, and python0.exe= python executable from virtual env).

BUT, here is what I get:

(envTest) C:\Users\user1\projects\env_testing>whereis python
C:\Python27\python.exe

(envTest) C:\Users\user1\projects\env_testing>whereis python3
C:\Users\user1\AppData\Local\Programs\Python\Python37\python3.exe

(envTest) C:\Users\user1\projects\env_testing>whereis python0
C:\Users\user1\Envs\envTest\Scripts\python0.exe

(envTest) C:\Users\user1\projects\env_testing>python --version
Python 2.7.16

(envTest) C:\Users\user1\projects\env_testing>python3 --version
Python 3.7.4

(envTest) C:\Users\user1\projects\env_testing>python0 --version
Python 2.7.16

(envTest) C:\Users\user1\projects\env_testing>

It looks to me, like I didn't get the right virtualenvwrapper when creating the envTest env, and thereby indirectly called the wrong python version.

How could I fix this?

I also tried to simply try the python3.x built-in venv, but using it, I get an Error message:

C:\Users\user1\projects>python3 -m venv ./venv_Test venvEnv
Error: [WinError 2] The system cannot find the file specified

even though it created the following directories, although without python executable

C:\Users\user1\projects\venv_Test>dir
...
30.01.2020  14:41    <DIR>          .
30.01.2020  14:41    <DIR>          ..
30.01.2020  14:41    <DIR>          Include
30.01.2020  14:41    <DIR>          Lib
30.01.2020  14:41               117 pyvenv.cfg
30.01.2020  14:41    <DIR>          Scripts
...

Copyright Notice:Content Author:「Schelmuffsky」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/59987647/problems-creating-virtual-env-with-different-python-version

More about “Problems creating virtual env with different Python version” related questions

Problems creating virtual env with different Python version

I'm working on a big project that needs to be ported from python2.7 to python3.7. For developing, I rely on virtual envs. For the 2.7v, I'm using a virtual environment created with the virtualenv ...

Show Detail

anaconda activate the system version of python instead of virtual env on Mac

I want to activate the anaconda virtual env on the command line. And I used the commands below to activate it. source activate py368 (or conda activate py368) (py368) **@** $ It seemed the virtua...

Show Detail

python virtual env issue

While using command pipenv shell to create virtual env for project it shows below error: “Creating a virtualenv for this project... Pipfile: /opt/fiware-env/ckan/Pipfile Using /usr/bin/python3.5 (3...

Show Detail

Creating Python virtual environment in different version than installed on Windows

To run some script I need specific version of python (3.7.1). On my PC I have python 3.7.3 For creating virtual environment I am using: python -m venv virtual Which gives me fully functional

Show Detail

Django virtual env issues with Python and Atom

I've been all over the site trying to find a solution for a problem i am running into with my virtual environment and the python version being used. I have installed mini conda I am on a Mac I have...

Show Detail

not able to activate the python virtual env vscode

I have my python 3.8 and 3.7 installed on my system. Python3.8 as active by default. Now I had created the python venv using following command with python3.7 virtualenv --python=C:\Users\sgarg\AppD...

Show Detail

Global packages in virtual environment with different Python version

Is it possible to use globally installed packages inside a virtual environment that has a different python version?The global Python version is 3.9.4, and I have created this virtual environment us...

Show Detail

problems creating virtualenv when installing two different versions of Python

I have installed Python 2.7, pip and virtualenv on my computer and I have created a virtual environment with this same version of Python. I installed some packages in this new virtual environment t...

Show Detail

How to copy python virtual env accessing global packages to a different machine

I have set up a python virtual env using $ virtualenv --system-site-packages env It works fine on the machine where I have set up the virtual env and I can access all the global packages in my sc...

Show Detail

miniconda not installing python in virtual env

I've recently installed miniconda and whenever I create a virtual env and try the command: python --version I get that python isn't recognised as an internal or external command, operable prgram or

Show Detail