3

I have both Python 3.7 and 3.6 installed. But in my profile I set to use 3.6 and this is indeed a version that gets reported by which python3.

$ which python3 /Library/Frameworks/Python.framework/Versions/3.6/bin/python3

I then create virtual env by running python3 -m venv venv

And everything in my venv gets linked to the 3.6. I confirm this with ls -la venv/bin and by inspecting venv/pyvenv.cfg.

I activate the venv virtual environment.

I then install a zappa library with pip install zappa.

And when I run zappa deploy, I get an error that Python 3.7 is not supported. Why would a library use the version of Python that is not configured within the virtualenv and how do I make it use the correct version?

(venv) $ zappa deploy
Traceback (most recent call last):
  File "/Users/t/Projects/djzappa/Spheres/venv/bin/zappa", line 7, in <module>
    from zappa.cli import handle
  File "/Users/t/Projects/djzappa/Spheres/venv/lib/python3.7/site-packages/zappa/__init__.py", line 12, in <module>
    raise RuntimeError(err_msg)
RuntimeError: This version of Python (3.7) is not supported!
Zappa (and AWS Lambda) support the following versions of Python: ['2.7', '3.6']

NOTE: I do NOT use virtualenv as everybody is suggesting, and as other existing answers are referring.

enter image description here

5
  • 1
    Possible duplicate of Using Python 3 in virtualenv Commented Nov 19, 2018 at 10:34
  • 1
    No it is not a duplicate. Commented Nov 19, 2018 at 10:42
  • use pip3 install zappa, pip may well point to the 3.7 version. Commented Nov 19, 2018 at 11:16
  • Yes, it is a duplicate actually. - The answer you marked as the answer, can be found in the one I marked. Commented Nov 19, 2018 at 12:17
  • Which one? Because I can't find a single one explaining the sequence of installations of different versions of Python - which is what solved MY problem. Including the comment discussion. Commented Nov 19, 2018 at 12:59

3 Answers 3

5

Use this when you create environment:

virtualenv --python=/usr/bin/python3.6 

But if you want to use venv, first of all, check whether python3 in your terminal refers to the python3.6 as you want.

If not - run your command with the full path to python3.6 instead of sole python3 in python3 -m venv venv.

Edit: why your alias python3 is referring to python3.7 - it probably depends on OS you use and sequence of installation. Hard to say.

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

13 Comments

I don't use virtualenv. I use 'python3 -m venv'.
Try using /usr/bin/python36 -m venv; If it does not works either, please install virtualenv.
$ /usr/bin/python36 -bash: /usr/bin/python36: No such file or directory
And this file is not a symlink? /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
It is even weirder and more disgusting than I thought
|
1

As an addition to the accepted answer, be also aware that changing the directory name where your venv is located causes using the default python and pip paths of your system, instead of using the venv one.

Comments

-1

The Python version is different from the virtualenv python version and that is why it is complaining. You can recreate your virtual environment(delete the existing one) and use the following command

virtualenv --python=your python version here venv Or

mkvirtualenv venv --python=your python version here

if you want to create your virtual environment using mkvirtualenv command.

1 Comment

I don't use virtualenv. I use 'python3 -m venv'.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.