I need to perform an import of a function on my python project.
I know there\'re dozens of similar questions on SO, however, unfortunately, I couldn\'t find the right so
I know you have already accepted an answer, but if you wanted a less "permanent" solution (that is to say, if you didn't want to install your code), another option would be to simply add the parent of your PythonClient directory to your path. This can be done permanently (which varies depending upon operating system) or temporarily in code:
import os
import sys
p = os.path.abspath('../..')
if p not in sys.path:
sys.path.append(p)
from PythonClient.hashes.hash_function import hash_function
Cheers!
The fact that you have an __init__.py
tells me that PythonClient is itself a library. Do from PythonClient.hashes.hash_function import hash_function
. I always like fully qualified paths.
You need to install your library too before you can import from it. That requires a setup.py file in your home directory. After that, you should pip install your library for testing, e.g., `pip install -e .