Python virtual environment with specific version on Windows

problem

I've set up a few Python projects recently and I needed to create each time a virtual environment with a specific Python version on Windows.

solution

Each time I ended up googling and getting to this Stack Overflow question: https://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv

The answer for Windows is there somewhere in comments, but it's hard to find, so here it is in plain sight:

py -3.12 -m venv my_env_name
Gravatar
Author: Dan Dumitru
Last Edit: December 10, 2024
Last Edit December 10, 2024
Created December 10, 2024
Views 11
Tags
Python

Join in!

I'm building here a library of useful solutions to software development problems.

If you like this project, create an account or add a bookmark, then come back here to write a post yourself when you run into something that might be useful to others...

>> read more

Your Comment

Feel free to post additional info or improvement suggestions.
preview
Optional, never shown, displays gravatar.

Formatting Tips

This editor uses Markdown to easily add code in your posts.

Triple backticks for full line(s) of code (or indent 4 spaces)

```
let foo = 'bar';
```

[link text](http://a.com)

*italic* **bold**

More Tips