4

I have Python 3.5 installed in my windows machine and that is the only version I have on my computer. I want to create a python2.7 virtual environment to try out a certain package. Is it possible to create a virtual environment with python2.7 binaries without installing Python 2.7 in my system?

2 Answers 2

1

To use a different Python interpreter, that interpreter needs to be on $PATH, which means a binary on your machine.

see --> https://stackoverflow.com/a/45293556/6813490

Sign up to request clarification or add additional context in comments.

2 Comments

That means I need to install python27?
yes indeed, although having multiple Python interpreters is not a hassle
1

You don't need to have your Python interpreter on $PATH, you can tell virtualenv where to find it. I found this blog post Installing Multiple Python Versions on Windows Using Virtualenv but the TL;DR is:

  1. Open Command Prompt and enter pip install virtualenv.
  2. Download the desired python version (do NOT add to PATH!), and remember the path\to\new_python.exe of the newly installed version.
  3. To create a virtualenv, open Command Prompt and enter virtualenv \path\to\env -p path\to\new_python.exe.
  4. To install packages:
    1. Activate virtualenv: open Command Prompt and enter path\to\env\Scripts\activate.bat.
    2. Install desired packages with pip.
    3. Deactivate with deactivate.

Note python3 -m venv \path\to\env doesn't seem to suppport the -p parameter, you have to use virtualenv.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.