Skip to main content
Solved

Python SDK using poetry


Forum|alt.badge.img+2

I have cloned the following in my local DEV folder.

using-cognite-python-sdk.git

I have also installed the dependencies that are defined in the pyproject.toml in the repo.

To run the code in jupyter notebooks. (Note: Change the "Kernel" to use the virtual environment created by poetry.) and add new libraries as needed.

 

How do I change the Kernel in jupyter notebook to the one created by poetry? When I open the jupyter notebook from the repo folder, it shows the general python3 (ipykernel) but this was present even before I installed poetry. 

So how do I change the kernel in my notebook.

 

Please advise.

 

Best answer by Kristian Gjestad Vangsnes

Thank you @eashwar11! Can you try to add ipykernel by running

poetry add ipykernel

and then run ‘poetry run python -m ipykernel install --user --name myname’ again?

View original
Did this topic help you find an answer to your question?

5 replies

Hi @eashwar11, if you have installed poetry and ran `poetry install`, have you activated the environment? if so, can you try installing the ipykernel directly : poetry run python -m ipykernel install --user --name myname ?


Forum|alt.badge.img+2
  • Author
  • 42 replies
  • March 3, 2023

Thanks @Kristian Gjestad Vangsnes . I can see the environment is activated (as shown below in BLUE). But when i try to install ipykernel directly, it is giving the following messages (highlighted in yellow). I am trying to clone the extractor-utils repo and work to create a custom extractor in my local.

D:\pycdf\python-extractor-utils-master\python-extractor-utils-master>poetry env list
cognite-extractor-utils-yeiQVxSK-py3.9 (Activated)

D:\pycdf\python-extractor-utils-master\python-extractor-utils-master>poetry run python -m ipykernel install --user --name eashwar_n
C:\Users\eashwar_n\AppData\Local\pypoetry\Cache\virtualenvs\cognite-extractor-utils-yeiQVxSK-py3.9\Scripts\python.exe: No module named ipykernel


Thank you @eashwar11! Can you try to add ipykernel by running

poetry add ipykernel

and then run ‘poetry run python -m ipykernel install --user --name myname’ again?


Forum|alt.badge.img+2
  • Author
  • 42 replies
  • March 3, 2023

Great! It worked now. I added the ipykernel and then ran the above command. After launching the jupyter notebook, I could see the new env with <myname> showing up in the notebook.

Thanks a lot!


No problem @eashwar11, thank you for reaching out! We will make sure that the documentation is updated.


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings