How can I fix ImportError: No module named numpy? - python

I am trying to run a python script which has the following statements:
import random as RD
import pylab as PL
import scipy as SP
import networkx as NX
Where can I download these packages?
I have installed these packages and I get the following error when I run my code
I am getting the following error when I run the code
Traceback (most recent call last):
File "C:\Documents and Settings\hplabs\Desktop\Dushyant\networkdemo.py", line 7, in <module>
import pylab as PL
File "C:\Python26\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python26\lib\site-packages\matplotlib\__init__.py", line 129, in <module>
from rcsetup import defaultParams, validate_backend, validate_toolbar
File "C:\Python26\lib\site-packages\matplotlib\rcsetup.py", line 19, in <module>
from matplotlib.colors import is_color_like
File "C:\Python26\lib\site-packages\matplotlib\colors.py", line 52, in <module>
import numpy as np
ImportError: No module named numpy

Here's a link to the non standard libraries. random is part of the standard library.
matplotlib
scipy
networkX
numpy (reuired by scipy)

'random' is shipped with the standard library
pylab and scipy are part of SciPy
Networkx is available here

random is a standard python library module, no need to install that.
pylab and scipy can be found on the SciPy site
networkx also has a site
BTW: These are all easily found using google.com

When installing Scipy, you also need to install numpy which it depends on. See here. You are getting the error because numpy is not installed on your system.

Related

How to fix ImportError : DLL load failed for scipy.spatial module?

It's been a week I have been searching for an answer, but I have not found a way to solve my problem.
I'm running python 3.6 on Windows, and I have this error :
Traceback (most recent call last):
File "C:/Alexis/folder/tag_activity.py", line 10, in <module>
from scipy.spatial.distance import cdist
File "C:\Users\Alexis\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\spatial\__init__.py", line 101, in <module>
from .qhull import *
ImportError: DLL load failed: Le module spécifié est introuvable.
Here is a few lines to give context :
# In tag_activity.py
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial.distance import cdist
import boto3
import requests
# In scipy.spatial module
from .kdtree import *
from .ckdtree import *
from .qhull import *
from ._spherical_voronoi import SphericalVoronoi
from ._plotutils import *
I really don't understand why it doesn't works, because when I try to access .qhull.py file with CTRL+click on Pycharm, I can access the module.
I've tried to reinstall scipy with adequate .whl file (scipy-1.3.1-cp36-cp36m-win_amd64.whl) from Christoph Gohlke website, but it doesn't solve anything.
Edit : I can't install python 3.7, I'm using libraries that aren't supported, and the script will run on servers using python 3.6
try installing through with the standard command line
pip install scipy
or clone on https://files.pythonhosted.org/packages/e1/9e/454b2dab5ee21f66ebf02ddbc63c5f074b21c44e66e1a509b38566cac9d9/scipy-1.3.1-cp37-cp37m-win32.whl

I cannot import pylab - even though matplotlib, numpy and scipy are already installed (Python)

I am sorry for asking this question again, but I could not find any answer to my problem that helped me. I don't have much experience with python. I use python version 3.6.8 on Windows and I have already installed matplotlib, numpy and scipy. The 'pylab.py' file is also contained in the matplotlib folder. Edit: Using matplotlib.pyplot also doesn't work.
Edit: After some more trials I got the error that the module 'six.names" could not be found. The six package has been installed.
import pylab
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pylab
ModuleNotFoundError: No module named 'pylab'
import matplotlib.pyplot
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
import matplotlib.pyplot
File "C:\...\Python36-32\lib\matplotlib\pyplot.py", line 30, in <module>
from cycler import cycler
File "C:\...\Python36-32\lib\cycler\cycler.py", line 48, in <module>
from six.moves import zip, reduce
ModuleNotFoundError: No module named 'six.moves'
Per https://matplotlib.org/faq/usage_faq.html#matplotlib-pyplot-and-pylab-how-are-they-related, pylab is not recommended; you should use pyplot instead.
The correct way to import either is
import matplotlib.pyplot # use this
import matplotlib.pylab # only if you cannot avoid it
(pyplot and pylab are not standalone modules, but submodules of matplotlib.)

Can not import pydelay

I have a homework to solve a delay differential equation using two packages, ddeint and pydelay. The problem is, I can't import pydelay to my program. It keeps saying that it can't import weave from scipy.
In [1]: import pydelay
Traceback (most recent call last):
File "<ipython-input-1-c7b60806236e>", line 1, in <module> import pydelay
File "c:\python27\lib\site-packages\pydelay\__init__.py", line 9, in <module> from _dde23 import dde23
File "c:\python27\lib\site-packages\pydelay\_dde23.py", line 32, in <module> from scipy import weave
ImportError: cannot import name weave
I use Windows 10 64 bit with Python 2.7, I write my program in Spyder 3.1.4. I have installed numpy 1.13.0+mkl so that I can install ddeint 0.1.2. I also have installed scipy 0.19.1 and weave 0.16.0. From what I've read, the new version of scipy doesn't have weave in it, and pydelay use weave from scipy, so I assume that my problem comes from that.
Is there any way for me to use pydelay with separated weave I've installed?

Python 2.5.... MatPlotLib doesn't install PyLab

I have NumPy and SciPy installed and working. I'm using Python 2.5 (MIT Intro to Programming course) so I've been installing the packages with .exe files instead of Pip or Anaconda. With MatPlotLib, I get the following errors during installation:
could not create: matplotlib-py2.5
could not create: python 2.5 matplotlib-1.0.0
could not set key value: "C:\Python25\Removematplotlib.exe" -u "C:\Python25\matplotlib-wininst.log"
I have a MatPlotLib folder in Python's Lib/site-packages directory. Importing matplotlib into IDLE works fine. But when I try to import pylab:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pylab
File "C:\Python25\Lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python25\Lib\site-packages\matplotlib\pylab.py", line 216, in <module>
from matplotlib import mpl # pulls in most modules
File "C:\Python25\Lib\site-packages\matplotlib\mpl.py", line 1, in <module>
from matplotlib import artist
File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 6, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
File "C:\Python25\Lib\site-packages\matplotlib\transforms.py", line 34, in <module>
from matplotlib._path import affine_transform
ImportError: DLL load failed: The specified module could not be found.
I've looked around on different message boards but can't find anyone else with this issue.
Any ideas?

ImportError: cannot import name flib

I want to use Python for trying out hddm.
I installed anaconda, Python 2.7. When I try to follow the hddm tutorial in the command line window in spyder, the following happens, which seems to be a problem in pymc:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import hddm
Traceback (most recent call last):
File "<ipython-input-24-17365318b31c>", line 1, in <module>
import hddm
File "/Users/c/anaconda/lib/python2.7/site-packages/hddm/__init__.py", line 7, in <module>
import likelihoods
File "/Users/c/anaconda/lib/python2.7/site-packages/hddm/likelihoods.py", line 2, in <module>
import pymc as pm
File "/Users/c/anaconda/lib/python2.7/site-packages/pymc/__init__.py", line 31, in <module>
from .distributions import *
File "/Users/c/anaconda/lib/python2.7/site-packages/pymc/distributions.py", line 30, in <module>
from . import flib, utils
ImportError: cannot import name flib
I work on Mac OS X 10.7. On the web, I find some comments concerning pymc possibly not being compiled with the correct version of gfortran, but the solutions all seem to be for windows. Also, I thought that this kind of problem should not happen with an integrated system like Anaconda?
There are two options:
use conda install -c conda.binstar.org/pymc pymc
install gfortran and use pip install -U pymc

Categories

Resources