Sunday, 19 June 2016

import - Python file structure about importing from other directories

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

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...