ModuleNotFoundError: No module named 'grakn.client'; 'grakn' is not a package
opened this issue · comments
Description
I've installed grakn-client through pip like mentioned on pypi or in the grakn docs. Installation worked successfully but after importing
from grakn.client import GraknClient
I get the Error:
ModuleNotFoundError: No module named 'grakn.client'; 'grakn' is not a package
Environment
- Windows 10 Pro - 64 Bit
- Grakn Core 1.7.1 hosted on premise on Ubuntu 18.04.4 LTS
- client-python 1.7.2 and for testing previous version while getting the same error
- Python version: first 3.8 then 3.6.8 and now through conda 3.7.7 everytime getting the same error
- Other environment details:
Reproducible Steps
Steps to create the smallest reproducible scenario:
- install python 3.6.8 on windows 10 Pro 64 Bit
- execute
pip install grakn-client - create python file and just add
from grakn.client import GraknClient
Expected Output
Nothing.
Actual Output
Traceback (most recent call last): File "c:/Users/Johannes/testing/grakn.py", line 1, in <module> from grakn.client import GraknClient File "c:\Users\Johannes\testing\grakn.py", line 1, in <module> from grakn.client import GraknClient ModuleNotFoundError: No module named 'grakn.client'; 'grakn' is not a package
Additional information
@meta-johannes
- Are you sure you're using the same Python interpreter when invoking
pipand when invoking that file? Usually, the command forpython3would bepip3. To test that, could you try installing some other package and importing it using the same commands? - in your interpreter, could you
import sys; print(sys.path)
Thank you @vmax for the fast answer.
I installed client python using the full path to my python executable:
C:/Users/Johannes/AppData/Local/Programs/Python/Python36/python.exe -m pip install grakn-client
and all my python programs I execute with
C:/Users/Johannes/AppData/Local/Programs/Python/Python36/python.exe c:/Users/Johannes/testing/grakn.py
so I'm relatively sure that both are using the same interpreter, isn't it so?
import sys; print(sys.path) says:
['c:\\Users\\Johannes\\testing', 'C:\\Users\\Johannes\\AppData\\Local\\Programs\\Python\\Python36\\python36.zip', 'C:\\Users\\Johannes\\AppData\\Local\\Programs\\Python\\Python36\\DLLs', 'C:\\Users\\Johannes\\AppData\\Local\\Programs\\Python\\Python36\\lib', 'C:\\Users\\Johannes\\AppData\\Local\\Programs\\Python\\Python36', 'C:\\Users\\Johannes\\AppData\\Roaming\\Python\\Python36\\site-packages', 'C:\\Users\\Johannes\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages']
@meta-johannes alright, now please look at the output of pip show grakn-client to see where that package is installed and see if that folder is in the sys.path
C:/Users/Johannes/AppData/Local/Programs/Python/Python36/python.exe -m pip show grakn-client
says
Name: grakn-client
Version: 1.7.2
Summary: Grakn Client for Python
Home-page: https://github.com/graknlabs/client-python/
Author: Grakn Labs
Author-email: community@grakn.ai
License: Apache-2.0
Location: c:\users\johannes\appdata\local\programs\python\python36\lib\site-packages
Requires: grpcio, protobuf, six
Required-by:
So the path to the installation of client python is in my python path.
Does nobody has the same error or can help me with that? :-(
It seems that it has something to do with Visual Studio Code.
I haven't seen this before, but if it is VS code then you can try to run your script from outside of vs code right?
are you using python through anaconda/conda? we don't currently officially support that
@flyingsilverfin yes I'm using conda with the package installed through pip. At a friend it's working fine under conda. We've checked many thing, reinstalled my conda, vs code, etc. but nothings working.
Try not using conda and straight pip and see if it works
Ok, now I completly reinstalled my Windows 10 because I thought this would fix the issue. After only installing Python 3.6.8 64 Bit and then pip install grakn-client which was successful I still get the same message. I'm not sure what is wrong.
Ok found the solution. I don't even want to share this because it is so stupid!!
My filename was "grakn.py". Because I import grakn. of course python says it is not a module because it want's to import the current file itself.
But hey, now my windows is clean and running perfectly.
good find! have fun with grakn :)


