When I try to run app.py (Python 3.3, PyCrypto 2.6) my virtualenv keeps returning the error listed above. My import statement is just from Crypto.Cipher import AES
I had the same problem (though on Linux). The solution was quite simple - add:
libraries:
- name: pycrypto
version: "2.6"
to my app.yaml
file. Since this worked correctly in the past, I assume this is a new requirement.
crypto
or pycrypto
anymore!As you can read on this page, the usage of pycrypto
is not safe anymore:
Pycrypto is vulnerable to a heap-based buffer overflow in the ALGnew function in block_templace.c. It allows remote attackers to execute arbitrary code in the python application. It was assigned the CVE-2013-7459 number.
Pycrypto didn’t release any fix to that vulnerability and no commit was made to the project since Jun 20, 2014.
pycryptodome
instead!Make sure to uninstall all versions of crypto
and pycrypto
first, then install pycryptodome
:
pip3 uninstall crypto
pip3 uninstall pycrypto
pip3 install pycryptodome
All of these three packages get installed to the same folder, named Crypto
. Installing different packages under the same folder name can be a common source for errors!
In order to avoid problems with pip packages in different versions or packages that install under the same folder (i.e. pycrypto
and pycryptodome
) you can make use of a so called virtual environment. There, the installed pip packages can be managed for every single project individually.
To install a virtual environment and setup everything, use the following commands:
# install python3 and pip3
sudo apt update
sudo apt upgrade
sudo apt install python3
sudo apt install python3-pip
# install virtualenv
pip3 install virtualenv
# install and create a virtual environment in your target folder
mkdir target_folder
cd target_folder
python3 -m virtualenv .
# now activate your venv and install pycryptodome
source bin/activate
pip3 install pycryptodome
# check if everything worked:
# start the interactive python console and import the Crypto module
# when there is no import error then it worked
python
>>> from Crypto.Cipher import AES
>>> exit()
# don't forget to deactivate your venv again
deactivate
For more information, see pycryptodome.org
Try with pip3:
sudo pip3 install pycrypto
I'm with 3.7. The issue remains after I try to install crypto. And pycrypto just fails in my case. So in the end my build passed via package below: pip install pycryptodome
This problem can be fixed by installing the C++ compiler (python27 or python26). Download it from Microsoft https://www.microsoft.com/en-us/download/details.aspx?id=44266 and re-run the command : pip install pycrypto
to run the gui web access when you kill the process of easy_install.exe
.
Uninstalling crypto
and pycrypto
works on me. Then install only pycrypto
:
pip uninstall crypto
pip uninstall pycrypto
pip install pycrypto