1

I'm running a local server in Python with GAE, and importing a 3rd party library, which in turn imports pycrypto. I installed it locally using pip and included it in my app.yaml file, but when I run the server, I get the following error:

ImportError: cannot import name OSRNG

Here's what my app.yaml looks like:

runtime: python27
threadsafe: 1

handlers:
- url: /.*
  script: main.app

libraries:
- name: pycrypto
  version: "latest"

I'm running homebrew python 2.7.

Manoj Jadhav
  • 1,270
  • 1
  • 15
  • 23

3 Answers3

1

The pycrypto library is built-in in the runtime environment, however you need to install it locally in order to run the local development server, as you did. It might just be a problem with versions, as the supported pycrypto versions are 2.3, 2.6 and 2.6.1.

Try installing the proper version with pip install pycrypto==2.6.1.

Then, change your app.yaml file to the appropriate version:

libraries:
- name: pycrypto
  version: "2.6.1"
dsesto
  • 7,864
  • 2
  • 33
  • 50
0

Official documentation seems to suggest that api_version in app.yaml is required.

A.Queue
  • 1,549
  • 6
  • 21
0

The problem for me was that google app engine uses its own python installation (in my case in "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython2\python.exe").

Once I installed pycrypto using that path, it worked fine:

.\python.exe -m pip install pycrypto

NOTE! Need to run cmd/powershell as administrator!

quano
  • 18,812
  • 25
  • 97
  • 108