I'm extremely new to Python and virtualenv, so I apologize if this is an obvious question. I've got a C drive and a D drive on my pc running windows 10. I have the python and scripts path set to the proper location on the D drive.
In console, i did a pip install virtualenv
and pip install virtualenvwrapper-win
. After that i navigated to a folder on my D drive where i want my projects. When I ran mkvirtualenv HelloWorld
, it seems to have created the virtualenvironment in my C:/users/me folder. Additionally, the virtual env was not activated by default and I was not moved to the correct directory in my console.
How can I ensure that mkvirtualenv
creates new virtual environments in the correct folder on my D drive? And what am I doing wrong to not activate virtual env after creation?
On VirtualEnvWrapper's documentation, they say "optionally":
That
%USERPROFILE%
part is why you're seeing a directory namedEnvs
created atC:/users/me
.I'm not posting this to act like a know-it-all; this tripped me up too as I just glazed right over it.
I did some research and it turns out in Windows CMD, you can do something like:
where `%cd% is your current directory. You'd think that this would set the environment variable permanently, but no, it doesn't. It's only temporary.
I also tried:
but the path was just ignored and was still created in %USERPROFILE%\Envs.
To set the
WORKON_HOME
environment variable permanently on your Windows machine, you have to go into the environment variables (search how to get there if you don't know how) and do the following:After you have set your
WORKON_HOME
directory, in Windows CMD prompt, you can then do (notice my current path is at C:\Django):This is what will appear on the screen:
When you do
mkvirtualenv name
it's creating the virtualenv in the current directory you're in in the shell. To create it in the place you want you either need to specify the path or navigate there and create the virtualenv