Jupyter fails importing qiime2

Hello everybody!

I'm recently trying to use dokdo to edit my qiime2 plots, and I need to run it in Jupyter, but after run jupyter notebook into a qiime2 environment, I'm not able to import qiime2, since I get the following error:

No module named 'qiime2'

Maybe there is some problem when executing jupyter from the ubuntu terminal, since it says that There are no terminals running in the running menu...

Thank you in advance.



Hello @Anuka, so you're opening a terminal, entering the qiime2 conda environment, then opening the jupyter notebook in the environment, but you can't import qiime2? If you open ipython in a terminal that's in a qiime2 conda environment, can you import qiime2 in that ipython? To me it sounds like your notebook is using the wrong python kernel for some reason.

1 Like

Yes, I can run the commands in ipython... so the problem is with kernel? I just have one option... python3(ipykernel)

Interesting, usually ipython and jupyter use the same kernel. I'm not sure exactly what the issue is, but it would make sense that you wouldn't be able to import qiime2 if your notebook was using the wrong python. Can you run which jupyter notebook in a terminal with your conda environment active and post the output here?

can you also run the following in a jupyter notebook opened inside of your conda environment and post the output here:

import sys

when running which jupyter notebook: /home/anuka/miniconda3/envs/qiime2-2022.2/bin/jupyter

when running import sys and sys.executable: '/home/anuka/miniconda3/bin/python3.9'

Yep, that is using the incorrect python. It's possible that the jupyter notebook in your conda environment is using a jupyter config that is telling it to use a specific version of python. First, can you go to the top of your notebook and select kernel then Change kernel, are there more options for you to choose under that menu? If there aren't, or if none of them are the correct python, can you do the following?

If you run the command jupyter --config-dir with your conda environment active, what do you get? Assuming you actually get a directory, if you look in that directory does it have a file called jupyter_notebook_config.json or something similar, and what are the contents of that file if it exists?

There are no more options for kernel, just python3(ipykernel).

When I run that command (jupyter --config-dir), this is the result: /home/anuka/.jupyter

No I don't see any file. I'll try to re-install jupyter.

It already worked!

I reinstalled jupyter in ubuntu and it already worked with python 3 (ipykernel). I don't know where the problem was, but thank you any case.



That's great! Very strange though. Not sure what caused it to not be working in the first place.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.