4

I am trying to figure out how to switch between different Python versions on my Mac using virtualenvwrapper package.

My Mac came with Python2.7 and I've installed the latest version (Python3.7). I have figured out how to make an environment with Python3.7 using the following:

mkvirtualenv -p /usr/local/bin/python3 p3

But when I check PYTHONPATH, VIRTUALENVWRAPPER_PYTHON, and VIRTUALENV_PYTHON, they all point to the original Python 2.7.

How do I know that the environment I created is actually running Python3?

I am new to virtual environments and the Mac world, so this has all be a bit confusing to figure out. I appreciate any input.

6
  • 1
    When you run python --version what do you get? Commented Oct 29, 2018 at 23:29
  • just install anaconda for mac, it's much easier Commented Oct 29, 2018 at 23:38
  • opening a python shell with just python should do the trick as well as it prints the version. Don't forget to deactivate and workon the different environments i.e be sure to switch between the environments. Commented Oct 29, 2018 at 23:42
  • @ArdentLearner You're right. Thank you! Commented Oct 30, 2018 at 0:23
  • @tmcnicol I got Python3.7, which is exactly what i wanted. Why is it that PYTHONPATH, for example, doesn't reflect the same version as the environment? Do environmental variables not change under different environments? Commented Oct 30, 2018 at 0:25

1 Answer 1

1

Do this:

python3.6 -m virtualenv /path/to/your/venv

This will guarantee your virtualenv to install for that specific python version.

If you are not sure where your python executable is, fire up a python console:

>>> import sys
>>> print(sys.executable)
/full/path/to/your/python/executable

You'll usually find other python versions lying there - usually they're symlinked to your /usr/local/bin/ which will make you able to call them by name , e.g. python3.6

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

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.