0

I have twitter package installed as the result of conda list | grep twitter is: python-twitter 3.5 py_0 conda-forge twitter 1.18.0 pypi_0 pypi

But if I try to import twitter in my jupyter notebook using import twitter it gives an ModuleNotFoundError: No module named 'twitter' error. What am I doing wrong?

nkhl
  • 140
  • 2
  • 13
  • 1
    It's possible your PATH got botched, conda environment deactivated, and/or `jupyter` launched from the wrong environment. You can run `which jupyter` from the command line to see what environment it's being launched from or `!which python` in the notebook to see what environment the notebook is using – Matt Thompson Oct 17 '20 at 18:39
  • @MattThompson, yeah I think that is what is happening. ```which jupyter``` resulted in ```/home/nikhil/anaconda3/bin/jupyter``` while I am currently working in env named 'Twits' which is at ```/home/nikhil/anaconda3/envs/twits```. What should I do launch jupyter lab from my env Twits? – nkhl Oct 17 '20 at 19:20
  • First, I'd make sure you have it installed in both environments (remember that a package available in one is not available in another automatically). Also make sure you're in that environment when you call `jupyter-lab my-notebook.ipynb`, and also that it is installed in that environment. – Matt Thompson Oct 17 '20 at 19:29
  • @MattThompson, I called ```jupyter notebook``` while I was in my env (twits) but the jupyter notebook that opened was in root. How to make sure that jupyter notebook is for that env only? – nkhl Oct 17 '20 at 19:33
  • 2
    Does this answer your question? [Conda environments not showing up in Jupyter Notebook](https://stackoverflow.com/questions/39604271/conda-environments-not-showing-up-in-jupyter-notebook) I would recommend the `nb_conda_kernels` plus `ipykernel` solution in your case. Also, very minor note: `conda list` accepts a regex argument, so `grep` is unneeded, instead try `conda list twitter`. – merv Oct 18 '20 at 01:08
  • 1
    @merv yeah that helped, thanks for pointing it out. – nkhl Oct 18 '20 at 03:23

0 Answers0