0

I have problems with importing some functions in the file stored in other directories and importing random method from Crypto library.

I installed Python34 and PyCrypto 2.6.1 in window 7.

Here is my file structure

my_project
       /dh
           /__pycache__
           /__init__.py
       ./lib
           /__init__.py
           /helpers.py

In the /dh/__init__.py file I have three import statements as follows


from Crypto.Hash import SHA256 -> it is fine


from Crypto.Random import random -> gives me error "from Crypto.Random import OSRNG ImportError: cannot import name 'OSRNG' "


from lib.helpers import read_hex --> gives me error "from lib.helpers import read_hex ImportError: No module named 'lib' "

I found out that there is not such file or folder OSRNG in Python34/Lib/sit-packages/Crypto/Random/

How can I fix these two errors?

Thanks guys

Michael
  • 63
  • 2
  • 2
  • 9

1 Answers1

0

Adding an answer as I don't have enough reputation to comment.

I tried this in my system, I am able to import all the modules/Classes mentioned in the question. I do see the OSRNG directory.

Are you sure you installed it properly? Try reinstalling it. Also, are you using a virtualenv? If so, may be you forgot to activate it?

Shiva
  • 2,627
  • 21
  • 33
  • Should I use virtualenv? To be honest I don't know about it can you tell a bit more about it? – Michael Apr 27 '17 at 11:20
  • You don't have to unless you are working on multiple projects each requiring a separate python environment. You can check out http://stackoverflow.com/questions/5844869/comprehensive-beginners-virtualenv-tutorial if you are interested to learn. Since you are not aware of virtualenv, I assume you have not used it. – Shiva Apr 27 '17 at 13:52
  • https://www.microsoft.com/en-us/download/details.aspx?id=44266 Install that first and then reinstall pycrypto. This should resolve your problem. – Shiva Apr 27 '17 at 13:54
  • oh I installed the file from your link and reinstalled the pycrypto but it still gives me errors – Michael Apr 27 '17 at 14:29
  • http://stackoverflow.com/questions/11405549/how-do-i-install-pycrypto-on-windows I hope that one helps :) – Shiva Apr 27 '17 at 14:38