Solved

install package 'cognite' for following Data Engineer Basics - Learn course

  • 11 April 2024
  • 2 replies
  • 29 views

Badge

Hello!

 

I am trying to follow along the Data Engineer Learn module. There are hands on exercises that needs me to install jupyter notebook - i used pip to do that. In the notebook 1_Authentication.ipynb, the package cognite is needed:

from cognite.client.credentials import OAuthInteractive
from cognite.client import CogniteClient, ClientConfig

returns the error

---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[5], line 10
1 ## !pip3 install cognite
2 ## !pip3 show cognite-sdk
3 ## !pip3 show cognite-sdk
(...)
8 #import cognite.client
9 #from cognite.client import CogniteClient
---> 10 from cognite.client.credentials import OAuthInteractive
11 from cognite.client import CogniteClient, ClientConfig

ModuleNotFoundError: No module named 'cognite.client'

 

I am able to install cognite using pip to version 0.04. However poetry add cognite in the ‘using-python-sdk’ directory returned an error: 

  at ~/Library/Application Support/pypoetry/venv/lib/python3.12/site-packages/poetry/installation/chef.py:164 in _prepare
160│
161│ error = ChefBuildError("\n\n".join(message_parts))
162│
163│ if error is not None:
→ 164│ raise error from None
165│
166│ return path
167│
168│ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with pyzmq (25.0.2) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "pyzmq (==25.0.2)"'.

The Poetry project has renamed the master branch to main. The use of the master branch is now deprecated and the branch will be removed in the near future. Please update your refs to use main branch instead. Alternatively consider using released versions.

How do I troubleshoot the “ModuleNotFoundError”, so I can successfully run the notebooks and follow along the course. I have been struck in this for 3 days now. kindly help.

icon

Best answer by Lavanya Kannan 12 April 2024, 17:24

View original

2 replies

Userlevel 1
Badge +2

Hi @Lavanya Kannan 

You should use “cognite-sdk” not simply “cognite”.
Meaning, either “pip install cognite-sdk”, or “poetry add cognite-sdk”

Also if you are in the root directory (where the pyproject.toml file is) you should also be able to just write “poetry install”

Let me know how it goes.
 

Badge

@Andrian Gasper I tried “pip install cognite-sdk” last night out of desperation (before seeing your response) and magically it worked. Prior to this I had tied a bunch of things - installing with pip3, poetry. I think I had run 

 

pip wheel --no-cache-dir --use-pep517 "pyzmq (==25.0.2)"

(think a lot of users mentioned this dependency not picked by poetry somehow?!)

to install “cognite” successfully in the meantime and this made

 

pip install cognite-sdk

or

poetry add cognite-sdk

run successfully.

Reply