First bear with me as I am relatively new to coding. I am trying to import numpy to Jupyter (localhost, webbased) using Python 3 and getting an error.
import numpy as np
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-0aa0b027fcb6> in <module>()
----> 1 import numpy as np
ModuleNotFoundError: No module named 'numpy'
What should I do? Many thanks.
Maybe try download Anaconda and using that as your interpreter. Pretty sure that comes preinstalled with Numpy.
Or check that you are following the correct way for installing the python 3 version: think this might help: Install numpy on python3.3 - Install pip for python3
have you tried !pip install numpy in hte python Notebook cell?
I had the same problem despite correct version of Python and numpy on my Ubuntu. Then I tried something that worked in Google Colab:
!pip install numpy
After that I was able to import numpy without further complications.
Related
Hi everyone im currently facing problems with importing NumPy in jupyter notebook.
My first line of code was import numpy as np it resulted into giving me:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-8b972f5c2406> in <module>
----> 1 import numpy as np
After that my second option was to install NumPy which I did using !pip3 install numpy and that gave me Requirement already satisfied: NumPy in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.19.0)
Can someone let me know if I should re-download pip or something is wrong in my files? Thank you.
Check what version of python is your jupyter running.
Its highly likely that its running python 2.x.
If so, try using !pip install numpy instead of !pip3 install numpy.
You need to go to your Terminal, and execute !pip install numpy or pip3 install numpy depending on which version of Python you are using.
In the terminal, check for your python version using below command:
python --version
if you are using version 2 or 3:
python -m pip install numpy
if you are using version 3 or higher:
python3 -m pip install numpy
This way you know about where the package will be installed
I'm new to python and Anaconda and I tried to run my code which contains Levenshtein import, however, it shows me this error:
ImportError Traceback (most recent call last)
<ipython-input-1-896847aaaa86> in <module>()
1 import pandas as pd
2 import numpy as np
----> 3 import Levenshtein as lv
4 import math
5 import re
ImportError: No module named 'Levenshtein'
Any recommendations regarding this, I owe you tons of thanks
The error happens because Anaconda does not ship with the Levenshtein package. You'll have to install it.
Usually, you want to install python packages on Jupyter Notebook by using the conda command. I was having trouble installing this package in particular on a Windows, however, simply because Windows Defender held out the process indefinitely.
The way I managed to install it as by using pip in Windows's cmd. First you have to figure out were the python executable from your Notebook is running.
In your notebook:
import sys
{sys.executable}
Copy the path the cell outputs, open the cmd. There, use the following command:
[PASTE THE PATH HERE] -m pip install python-levenshtein
After that you should be able to import Levenshtein.
I am trying to use Matplotlib in my conda environment (Python 3.6) I am getting this error. Does anyone have an idea how to fix this?
import matplotlib.pyplot as plt
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
....
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\tri\triangulation.py in <module>()
4 import six
5
----> 6 import matplotlib._tri as _tri
7 import matplotlib._qhull as _qhull
8 import numpy as np
AttributeError: module 'matplotlib' has no attribute '_tri'
Please let me know if I need to post more details of the error.
I feel like you have mismatched binaries, unfortunately, I can't reproduce your error because mine works.
(1): Perhaps try to uninstall matplotlib and then re-install it again
conda uninstall matplotlib
conda install matplotlib
(2) try the output conda list and conda info then analyze it or post it here maybe so we can analyze it?
(3) Try the following commands maybe they will work:
conda update --all
(4) if this doesn't work uninstall Anaconda maybe and try to reinstall the latest version of it.
I am new to python, and trying to run this example in Jupyter notebook. Whenever I run following
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.api import SimpleExpSmoothing
It gives me following error
ImportError Traceback (most recent call last)
<ipython-input-5-a15788c08ca7> in <module>()
3 import pandas as pd
4 import matplotlib.pyplot as plt
----> 5 from statsmodels.tsa.api import SimpleExpSmoothing
ImportError: cannot import name 'SimpleExpSmoothing'
Although, I have installed statsmodels (0.8.0) by
pip install statsmodels
like other packages (numpy, pandas etc.). I checked on git, api file contains this method but my api file (obtained through pip) doesn't have this method. Maybe I am not getting the git version (seems latest one) through pip? I am working in windows and I also tried on mac OSX, and result is same. I tried to do a copy/paste attempt for missing files/code in files from git (not a good way) but it doesn't help. I would appreciate your suggestions here.
EDIT
So the solution for Jupyter (thanks to #user333700) is to install master branch directly from git by
pip install git+https://github.com/statsmodels/statsmodels.git
I am extending my question for PyCharm, how can I add a git package within PyCharm? This link does not help.
For future reference another solution which worked for me is to pip install the latest version directly:
pip install statsmodels==0.9.0rc1
Importing scipy in iPython gave me:
In [1]: import scipy
-----------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-4dc45f4c0083> in <module>()
----> 1 import scipy
/usr/local/lib/python2.7/site-packages/scipy/__init__.py in <module>()
/usr/local/lib/python2.7/site-packages/scipy/_lib/_ccallback.py in <module>()
ImportError: cannot import name _ccallback_c
In [2]:
Did a complete update of all the files of Anaconda
> conda update --all
and the error remains. Did a complete search on the web and there are similar problems but without solutions. Can you help me?
i am giving you two solutions which might work by my expereince
1. create a virtualenv and install the scipy package in that virtualenv and give path like this
import sys
sys.path.append('/home/shashi/.virtualenvs/venv/lib/python2.7/site-packages/')
import scipy
2.
Download the source code https://github.com/scipy/scipy/archive/v0.18.0-1.zipand unpack it. Open a command window in the folder where the setup.py of the module is located and type
scipy python setup.py install
It looks like scipy is not installed
conda install -c anaconda scipy
Try this and let us know if you receive the error again
Cheers!