torch module not found in jupyter notebook - jupyter-notebook

I am trying to import torch in a jupyter notebook python file and getting this error :
ModuleNotFoundError: No module named 'torch'
Also I have it installed in the created environment :
(pytorch_project) C:\Users\user>python
Python 3.7.15 (default, Nov 24 2022, 18:44:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>>
How can I make it work in the jupyter notebook also ?

The most likely reason is that you didn't install jupyter notebook in you conda env. Test it by
where jupyter
in you current env.
If the path doest not contain pytorch_project, you need to install jupyter for your current conda env:
pip install jupyter
Then, reactivate the env if needed.

Related

How can I open jupyter notebook in venv to my drake work correct

I install drake via pip in venv and I want open files from course underactuated.
I start venv by typing:
source env/bin/activate
Drake installed correct because of output of python3 -c 'import pydrake.all; print(pydrake.__file__)':
(env) dmitriy#dmitriy:~/git/underactuated$ python3 -c 'import pydrake.all; print(pydrake.__file__)'
/home/dmitriy/env/lib/python3.8/site-packages/pydrake/__init__.py
But when I try run it in Jupyter notebook with Kernel env I have:
ModuleNotFoundError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import pydrake.all; print(pydrake.__file__)
ModuleNotFoundError: No module named 'pydrake'
How can I open jupyter notebook in venv to my drake work correct ?
This is because I have not installed jupyter / IPython in your virtualenv.
This is the solution: Running Jupyter notebook in a virtualenv: installed sklearn module not available

some modules could not be import on jupyter notebook after installed from miniforge

I got some error like ModuleNotFoundError: No module named 'numpy' on apple silicon MacBook Pro. Since some modules can not install on MacBook by pip, then I used miniforge and conda successfully to install numpy, mathplot and pandas. However, those modules could be imported on jupyter notebook.
Any suggestions for solving this?

in Jupyter Notebook ModuleNotFoundError: No module named 'plotly'

I installed plotly library using anaconda prompt and it is appearing in my conda list. I can use it in Spyder but when i Import it in my Jupyter Notebook it Shows an Import error.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-182e2a6c8e92> in <module>
----> 1 import plotly as py
ModuleNotFoundError: No module named 'plotly'
But in my conda list it is seen as this.
plotly 3.10.0 py_0 conda-forge
Your Jupyter Notebook is probably not part of the Anaconda. Hence it is not recognising packages installed through Anaconda.
Solution 1
install Jupyter Notebook in Anaconda and try to run notebooks from there. When you will import plotly there it will be imported.
Solution 2
install pip. Here's how: how to install pip
Then use pip install plotly in command prompt.
You will be able to import plotly in Jupyter now.
Feel free to comment if you have any questions.

Failed to run IPython Notebook: bash: IPython: command not found

I've installed Ipython 6.0.0 successfully using Pip3:
pip3 install IPython
but when tried to run the command
Ipython
I got this error:
bash: IPython: command not found
This is the pip list result:
ipykernel (5.1.3)
ipython (6.0.0)
ipython-genutils (0.2.0)
..
..
notebook (6.0.2)
and this is the result of pip3 show IPython
Name: ipython
Version: 6.0.0
Summary: IPython: Productive Interactive Computing
Home-page: https://ipython.org
Author: The IPython Development Team
Author-email: ipython-dev#python.org
License: BSD
Location: /home/pi/.local/lib/python3.5/site-packages
Requires: setuptools, traitlets, jedi, pexpect, pygments, pickleshare, simplegeneric, prompt-toolkit, decorator
This is a problem of case sensitivity...
The correct typography is IPython.
pip is not case sensitive, see Is PyPI case sensitive?
IPython is installed as ipython (lowercase), as shown in your pip3 show IPython
bash is case sensitive...
So, just enter ipython.
As you have specified pip3, I would also recommend to invoke ipython3 to avoid python2/3 confusions.

Jupyter: jupyter-notebook can not import module statsmodels

I have installed jupyter notebook in MacOS 10.9 Mavericks, using command
pip3 install jupyter
I can import some libraries like numpy, pandas and run Jupiter notebook normally, however, if I import the module statsmodels, it says No Module named "statsmodels'.
How can we run the installed library statsmodels in jupyter-notebook?
I had the same problem.
That's because the module has been install for python2 and not for python3 that you are using as well.
Find your python3 bin related to jupyter.
$jupyter --paths
Mine was at /usr/local/Cellar/python3/3.5.2_3/bin
run :
$python3 -mpip install statsmodels
cheers

Resources