Jupyter Notebook can't find modules for python 3.6
Question:
Not sure what happened but whenever I use ipython, hydrogen (atom) or jupyter notebook can’t find any of the installed modules. I know I have pandas installed but the notebook says its not found.
I should add that when I run the script normally (python script.py
) it does import without any errors.
Suggestions?
Thanks!
Answers:
Try the following:
pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
Make sure that Panda is installed using pip3.
Issue seems to be resolved by running
pip3 install
rather than pip install
The commands:
pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
worked for me only after I re-installed pip (note I was having the issue for python 3.7).
For that I did:
pip uninstall pip
then I used the (deprecated) command:
sudo easy_install pip
I also deleted any pip related thing in /usr/local/bin
with the command:
rm -rf pip*
hopefully, this is helpful to someone else 🙂
I was having a similar issue. I installed a text processing tool using pip3. The installation was successful and I was able to run the test-code from the terminal, however I was unable to execute the same code from jupyter notebook
. Checked that the sys.version
was 3.7.1
in notebook but the terminal version was 3.6.9
.
The problem was resolved after executing the following commands and relaunching the notebook:
pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
For Anaconda/Jupyter Notebook:
This solved my problem.
Firstly go to your Anaconda Prompt.
Then activate your environment (or skip this if you want to do it in base)
pip3 install ipykernel --upgrade
Then put this code.
python -m ipykernel install --user --name torch --display-name "PyTorch (base)"
Here, torch
= name of your virtual env (put anaconda-base
for the base environment)
PyTorch (base)
= display name you want to show in the kernel; replace it with your wish.
Then you will see the option to change the kernel (From Kernel Option) to your virtual environment you are looking for.
Before:
After:
And if it is in VS Code, please check this answer. This solves it perfectly.
I had the same problem for my jupyter notebook. I installed the modules using the computers terminal and then when I tried loading them in my jupyter notebook, I couldn’t load the modules but they were working just fine in the terminal.
At first, i checked the python versions and the terminal was running a python 3.8.5 version and the jupyter notebook was running 3.8.3, I thought this was the reason behind the problem and I updated the whole anaconda package but it still didn’t work.
Then I opened the anaconda prompt and installed the package again and i saw that most of the package was already installed and said requirement satisfied but there was just one part that got installed in the anaconda prompt. (Note: I never uninstalled the package in any terminal, and just installed it again in the anaconda prompt). After installing it in the anaconda prompt, it started working just fine.
In summary, try and install the package again in the anaconda prompt.
pip install (module_name)
Hope this will be of some help!!
I had the same issue with other packages (scikit-commpy and ModulationPy).
import <package_name>
was working on a script.py but not on a notebook.ipynb
What worked for me:
to run !pip install <package_name>
inside the notebook.
You only need to do it once
(it will probably say "dependencies already installed" but afterwards it will solve the issue).
what didn’t work for me but might be helpful:
- compare sys.version from both script.py and notebook.ipynb
- call
help('modules')
on both and compare
- you can also do
help('modules <package_name>')
for filtering the long list to your specific package.
- reinstalling any of the following packages:
- defected package
- ipython
- ipykernel
- on Pycharm: File > Invalidate caches
I had the exact same problem on a newly installed virtual env.
Turned out the problem was i was using an old version of pip and jupyter.
The below did the trick for me:
$pip3 install pip --upgrade
$pip3 install jupyter --upgrade
Not sure what happened but whenever I use ipython, hydrogen (atom) or jupyter notebook can’t find any of the installed modules. I know I have pandas installed but the notebook says its not found.
I should add that when I run the script normally (python script.py
) it does import without any errors.
Suggestions?
Thanks!
Try the following:
pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
Make sure that Panda is installed using pip3.
Issue seems to be resolved by running
pip3 install
rather than pip install
The commands:
pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
worked for me only after I re-installed pip (note I was having the issue for python 3.7).
For that I did:
pip uninstall pip
then I used the (deprecated) command:
sudo easy_install pip
I also deleted any pip related thing in /usr/local/bin
with the command:
rm -rf pip*
hopefully, this is helpful to someone else 🙂
I was having a similar issue. I installed a text processing tool using pip3. The installation was successful and I was able to run the test-code from the terminal, however I was unable to execute the same code from jupyter notebook
. Checked that the sys.version
was 3.7.1
in notebook but the terminal version was 3.6.9
.
The problem was resolved after executing the following commands and relaunching the notebook:
pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
For Anaconda/Jupyter Notebook:
This solved my problem.
Firstly go to your Anaconda Prompt.
Then activate your environment (or skip this if you want to do it in base)
pip3 install ipykernel --upgrade
Then put this code.
python -m ipykernel install --user --name torch --display-name "PyTorch (base)"
Here, torch
= name of your virtual env (put anaconda-base
for the base environment)
PyTorch (base)
= display name you want to show in the kernel; replace it with your wish.
Then you will see the option to change the kernel (From Kernel Option) to your virtual environment you are looking for.
Before:
After:
And if it is in VS Code, please check this answer. This solves it perfectly.
I had the same problem for my jupyter notebook. I installed the modules using the computers terminal and then when I tried loading them in my jupyter notebook, I couldn’t load the modules but they were working just fine in the terminal.
At first, i checked the python versions and the terminal was running a python 3.8.5 version and the jupyter notebook was running 3.8.3, I thought this was the reason behind the problem and I updated the whole anaconda package but it still didn’t work.
Then I opened the anaconda prompt and installed the package again and i saw that most of the package was already installed and said requirement satisfied but there was just one part that got installed in the anaconda prompt. (Note: I never uninstalled the package in any terminal, and just installed it again in the anaconda prompt). After installing it in the anaconda prompt, it started working just fine.
In summary, try and install the package again in the anaconda prompt.
pip install (module_name)
Hope this will be of some help!!
I had the same issue with other packages (scikit-commpy and ModulationPy).
import <package_name>
was working on a script.py but not on a notebook.ipynb
What worked for me:
to run !pip install <package_name>
inside the notebook.
You only need to do it once
(it will probably say "dependencies already installed" but afterwards it will solve the issue).
what didn’t work for me but might be helpful:
- compare sys.version from both script.py and notebook.ipynb
- call
help('modules')
on both and compare- you can also do
help('modules <package_name>')
for filtering the long list to your specific package.
- you can also do
- reinstalling any of the following packages:
- defected package
- ipython
- ipykernel
- on Pycharm: File > Invalidate caches
I had the exact same problem on a newly installed virtual env.
Turned out the problem was i was using an old version of pip and jupyter.
The below did the trick for me:
$pip3 install pip --upgrade
$pip3 install jupyter --upgrade