Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is AWS's Chalice for Python not respecting my virtualenv?

I'm attempting to deploy a chalice application following the tutorial. I'm using a virtualenv with python3.6. My application is dependent on a github repo in the requirements.txt and that repo's requirements.txt depends on several libraries.

I can run the application just fine with python -i app.py and I can execute my endpoints properly live in the REPL.

However, when I run chalice deploy I get an error complaining about a module required by the github repo I require.

File "/usr/local/lib/python2.7/dist-packages/chalice/deploy/packager.py", line 715, in download_all_dependencies
raise NoSuchPackageError(str(package_name))
NoSuchPackageError: Could not satisfy the requirement: PyQt5>=5.8.1

Notice, however, that this chalice library being used is 2.7. I'm in a virtualenv that is set to python3.6.

I realized that I had previously installed chalice globally, which might have been a mistake. So I pip uninstalled chalice globally, but it's still installed in my virtualenv.

Now rerunning chalice, I get

$ chalice --version
bash: /usr/local/bin/chalice: No such file or directory

I tried rerunning the install of chalice to the local virtualenv but it didn't change anything.

What am I doing wrong here?

like image 679
mmachenry Avatar asked Nov 17 '22 10:11

mmachenry


1 Answers

It could be multiple reasons.

I'm assuming your virtualenv is called venv, if not change it accordingly.

You have not activated your virtualenv.

Fix:

source venv/bin/activate 

You activated your virtualenv, but the path does not match.

Fix:

echo $PATH
/Users/[yourpath]/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/bin

If /Users/[yourpath]/venv/bin is not correct, check:

grep "VIRTUAL_ENV=" venv/bin/activate
VIRTUAL_ENV="/Users/[yourpath]/venv"

Then update venv/bin/activate accordingly.

Note: The virtualenv folder should not be added into your repo. This may be the source of your issues.

If you want to ensure everyone has matching dependencies run:

python -m pip freeze > requirements.txt
like image 157
albert Avatar answered Mar 04 '23 22:03

albert