- Settings:
Page
Normal
Plain layout without fancy styles
Font
Normal
Large fonts
Very large fonts
Colour
Normal
Restful colour scheme
Light text on a dark background

Note: user account creation on this site has been disabled.

Programming, speculative fiction, science, technology
Powered by Drupal, an open source content management system
Scope
Include Children
If you select a term with children (sub-terms), do you want those child terms automatically included in the search? This requires that "Items containing" be "any."
Categories

Everything in the Events vocabulary

"Events" is used for: Convention Post, Page, Story.

People mentioned in the articles

"People" is used for: Page, Convention Post, Story.

Themes mentioned in the article

"Themes" is used for: Page, Convention Post, Story.
Skip to top of page

Creating a virtualenv with Python 3 on Windows 10

(* if you have both Python 2 and Python 3 on your machine. If you only have Python 3, you probably don't need this article.)

I wanted to install Python 3 on Windows 10, and use it in a virtualenv. Eventually I wanted to get my Flask web application to run on Python 3.

The steps for that are not too difficult, but there are a few gotchas along the way. And you know what that means, Gentle Reader. It means that when I have to do it again -- let's say, months from now -- I will have to hunt down the solutions to all the gotchas again. So I decided to take lessons from the past and write it all down. And share it with those of you who don't want waste time hunting down the answers. So, this is what I did.

Note that wherever the instructions reference the Python path, if you installed a version of Python higher than 3.6, your path to Python 3 probably won't be Python36 -- it will probably end in a different number.

First I installed Python 3. Installation for Windows 10 was straightforward, even though I deviated from the default options in the installation wizard by installing Python for all users (the default is only for your user). This caused it install itself in C:\Program Files\Python36 directory, instead of locally in my user's AppData directory.

Then I ran pip install virtualenv, as recommended in this page on Python virtualenv installation on Windows.

Then I ran the next command the above page tells you to run:

pip install virtualenvwrapper-win

It installed itself. Then I tried to create a virtualenv:

mkvirtualenv SCP3

Ha! It created a virtualenv with Python 2 in it, because I also had Python 2 on my machine! I wanted Python 3, so after some searching I found that you need to pass to mkvirtualenv a path to the Python executable you want it to use.

Being wise in the ways of Windows paths with spaces in them, I tried like this:

mkvirtualenv --python="C:\Program Files\Python36\python" SCP3

where SCP3 is the name of my virtualenv.

Did that work? Nooo! Now it was saying the path C:\Program Files\Python36\python does not exist -- even though I can type C:\Program Files\Python36\python at the command prompt and start the Python interpreter! So it does exist!

Upon further search, this page told me that the command I used was basically correct, except I had to add ".exe" at the end of "python", like this:

mkvirtualenv --python="C:\Program Files\Python36\python.exe" SCP3

(That's actually a virtualenv issue described here).

And there you go -- I got a virtualenv with Python 3!

Note that this "complicated" command is only necessary if you have both Python 2 and Python 3 on your machine. If you only have Python 3, there won't be any other Python executable in your Windows PATH environmental variable, and you can probably run just mkvirtualenv SCP3.