I am currently using Amazon Deep Learning AMI (Ubuntu) Version 2. It comes with major deep learning framework (such as tensorflow, theano, etc) installed.
In console, I am able to import theano, tensorflow and others.
However, when I open jupyter notebook, I can't import import them.
It gives the following error.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-4c17dd4059b8> in <module>()
----> 1 import Theano
ModuleNotFoundError: No module named 'Theano'
Does anybody know what is the problem?
could you try latest DLAMI v20.0 which comes with Theano 1.0.3?
Also, when you try to import theano, did you try to source activate theano_<pythonenv>, or switch kernel in notebook? Please note, theano is only installed in accordingly conda environment.
Related
can you help me out with this
I'm trying to import seaborn as sns
but on my screen, it just showed
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'seaborn'
I tried to uninstall then re-installed seaborn on anaconda so many times but it doesn't work
Thank you for your help
Please, check if, in VSCode, you are using the Python environment in which you installed Seaborn. Refer to this post. You may be using a Python environment that is not from Anaconda.
You may also try to install the package via VSCode, using the normal conda or pip commands as they tell here. In this case, the package is installed in the environment in use.
I recently got into development with Python running on WSL (Ubuntu 18.04 LTS).
I followed the documentation from here and I'm able to run simple python scripts.
I started playing around with libraries that I installed using the pip3 command such as numpy and pandas and these work fine.
The problem arises when I try to use the statsmodels package.
I've installed it using pip3 install statsmodels
I can see the package in /home/username/.local/lib/python3.6/site-packages/statsmodels I can even see the api.py file in that directory, however, when I type import statsmodels.api as sm as recommended on the statsmodels website I get:
Console output:
username#DESKTOP-1JP4BIE:/mnt/c/users/username/dev/project/playground$ python3 statsmodels.py
Traceback (most recent call last):
File "statsmodels.py", line 5, in <module>
import statsmodels.api as sm
File "/mnt/c/username/chris/dev/project/playground/statsmodels.py", line 5, in <module>
import statsmodels.api as sm
ModuleNotFoundError: No module named 'statsmodels.api'; 'statsmodels' is not a package
I've tried uninstalling and reinstalling (did not work)
I really can't see anything that differentiates this package from the others that I've installed. Does anyone have any insights?
Thanks #Vorsprung durch Technik
The issue was that my file name was statsmodels.py.
I'll remember to be more careful when naming my python files.
I have opened up a Jupyter Notebook and tried to import a module from pyomo but get the following:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-f9221793da50> in <module>
----> 1 from pyomo.environ import *
ModuleNotFoundError: No module named 'pyomo'
When I run this code in PyCharm however I get no problems with the module not being found. Can someone help me to understand why Jupyter is unable to find the module yet PyCharm is able to? If there is some information that I am missing that would be useful please let me know and I will update accordingly.
You have to install it. Put this line as the first line in jupyter notebook
!pip install pyomo
note that any missing module is installed like this.
I have both Python 2.7 and 3.6 working on my machine. Numpy and Pandas both load, for either version of Python, in the terminal. However, when I try to access them from inside Jupyter notebook, I get the following error messages:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-4ee716103900> in <module>()
----> 1 import numpy as np
ModuleNotFoundError: No module named 'numpy'
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-af55e7023913> in <module>()
----> 1 import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Here is a screenshot of the problem as well:
If you look in the top right hand corner of the screenshot, you will notice where it says "Python3". I have seen video tutorials on Jupyter where clicking on that button generates a drop down list, allowing users to select alternate versions of Python. However, when I click on that button, nothing happens.
I noticed that a similar question was asked before here:
numpy & pandas 'ModuleNotFoundEror' in Jupyter notebook (Python 3)
However, very little information was provided and no resolution seems to have been found.
Another similar question provided a hint at an answer that was slightly more promising. It suggested running the following code both from terminal and from inside Jupyter, to make sure they match.
import sys; sys.executable
failed to import numpy as np when I worked with jupyter notebook
From terminal using Python 2.7.10>>
import sys; sys.executable
'/usr/bin/python'
From terminal using Python 3.6.1>>
import sys; sys.executable
'/usr/local/bin/python3'
From Jupyter>>
'/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6'
Have you checked this solution:
Failure to import numpy in Jupyter notebook ?
In your Jupyter screenshot, you're using a Python 3 kernel.
Make sure you have NumPy (and any others you might want to use) installed in your selected Python 3 environment.
1st, the Disclaimer: I looked at numerous questions here, there is question about uninstalling all pip–installed, uninstalling matplotlib, moving to 3.5 from 2.7, –– but I didn't find an answer to my specific problem. Sorry if I didn't look hard enough.
Basically, my problem is I have a mess of different packages installed by different means at different times. Manifestations of this are:
1) I can import numpy from python but not from Jupyter notebook:
------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-5a0bd626bb1d> in <module>()
----> 1 import numpy
ImportError: No module named numpy
2) I cannot import nltk:
...
File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling
likely many more.
I recently uninstalled jupyter and anaconda, installed anaconda again, - this didn't help.
I cannot uninstall numpy / scipy , although I can use them (?!?):
>:~%python -c 'from numpy.random import rand; print rand()'
0.946167984715
>:~%pip uninstall numpy
Cannot uninstall requirement numpy, not installed
I have two versions of Python:
2.7.11 under /usr/local/bin/ pointing to /usr/local/Cellar/python/2.7.11/bin/python
2.7.10 under /usr/bin/ pointing to
/System/Library/Frameworks/Python.framework/Versions
-- although the default is 2.7.10 (numpy works with it), and I think 2.7.11 was added by Anaconda (incorrectly, because it doesn't see numpy).
Yesterday I uninstalled everything I could think of, then upgraded to a new version of Mac OS (10.12.2 Sierra), and then re-installed anaconda – in vain.
I am close to reformatting the disk and starting from scratch.
Is there a better option?
Thank you! and sorry for so many details.
Not sure exactly on a MAC but these are the things to try on windows and it is probably similar on MAC.
Start with a clean install of anaconda then try "where python" and "where jupyter" (it is "which" instead of "where" on linux). This tells you where it is looking for the executables. Both should be subfolders of anaconda. If they are not check your PATH variable.
Now start python or jupyter; import sys and try sys.path. That tells you where python is looking for stuff. It should look only in anaconda sub folders.