typedb / typedb-driver-python

TypeDB Driver for Python

Home Page:https://typedb.com

Repository from Github https://github.comtypedb/typedb-driver-pythonRepository from Github https://github.comtypedb/typedb-driver-python

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

  1. Windows 10 Pro - 64 Bit
  2. Grakn Core 1.7.1 hosted on premise on Ubuntu 18.04.4 LTS
  3. client-python 1.7.2 and for testing previous version while getting the same error
  4. Python version: first 3.8 then 3.6.8 and now through conda 3.7.7 everytime getting the same error
  5. Other environment details:

Reproducible Steps

Steps to create the smallest reproducible scenario:

  1. install python 3.6.8 on windows 10 Pro 64 Bit
  2. execute pip install grakn-client
  3. 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 pip and when invoking that file? Usually, the command for python3 would be pip3. 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

I've noticed another interesting thing:

image

@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.

Again, the same strange behaviour that if I execute python directyl from my home directory I can import grakn.client. As soon as i switch the directory to ./testing it is not working anymore. This time Python 3.6.8 64B directly installed on my 64 Bit Windows 10 Pro edition.

image

Ok it looks like I'm getting a little closer to the actual issue. If i switch directory from homedir to ./Documents I can also include from grakn.client import GraknClient.
image

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 :)