Python cannot import scipy - python

I have Python 3.7.3 installed and installed numpy, scipy via pip (cmd -> python -m pip install --user numpy scipy) and am able to import numpy, scipy if I use an admin command prompt to import both numpy and scipy. However, if I don't use an admin cmd prompt, or try to import scipy from the Python shell, I receive traceback errors like the following:
>>> import numpy
>>> import scipy
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
import scipy
ModuleNotFoundError: No module named 'scipy'
Does this traceback error come from not installing scipy in a certain way? Thanks for the help in advance.
When doing checking pip and python versions in cmd, here's my output:
pip --version
pip 19.1 from c:\program files\python37\lib\site-packages\pip (python 3.7)
python --version
Python 3.7.3

Add the location of your python scripts to the Path in Environment Variables.
C:\Users\User_Name\AppData\Roaming\Python\Python37\Scripts
You mentioned that you've already installed the packages. And the packages are stored in the site-packages file inside Python37 folder. So the error must be because you didn't add these to the path.

Related

problem runnig a python code via ubuntu bash shell in windows 10

I have a code in python which uses numpy and when I try to run it on ubuntu bash shell in windows 10 there is an error like this:
Traceback (most recent call last):
File "kepler.py", line 2, in <module>
import numpy as np
ImportError: No module named 'numpy'
while numpy has already been installed in my windows and when I try the same code via windows command prompt it works well. I have tried to install numpy via ubuntu bash shell with this command
pip install numpy --user
The installation finishes successfully but when running the code "kepler.py" that error message shows up again. Then I type again
pip install numpy --user
but I get this message:
Requirement already satisfied: numpy in ./.local/lib/python3.6/site-packages (1.16.3)

Spyder not finding modules installed with anaconda

I have a newly installed Anaconda and tried to run an old code that uses scipy, numpy and os using Spyder 3.2.6. and get an error. When trying to import numpy from the IPythoin console I get
import numpy as np
Traceback (most recent call last):
File "<ipython-input-4-0aa0b027fcb6>", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
The os module however does get imported and works. I tried running python importing both scipy and numpy and I don't have any issue. I'm running just one Anaconda environment, so there's no mistake there.
Assuming you're using Anaconda Prompt:
Try installing Spyder into that environment via "conda install spyder", and then run spyder from that environment via "spyder".
I had the same issue. I just wrote this line in Anaconda Prompt instead of OS command prompt:
pip install <module>
It's obvious that <module> will be replaced by the desired module name.

Numpy not found after installation

I just installed numpy on my PC (running windows 10, running python 3.5.2) using WinPython, but when i try to import it in IDLE with: import numpy I get the ImportError: Traceback (most recent call last):
File "C:\Users\MY_USERNAME\Desktop\DATA\dataScience1.py", line 1, in <module>
import numpy
ImportError: No module named 'numpy'.
Did I possibly install it incorrectly, or do I need to do something else before it can be used?
In Linux and Mac OS systems we can install modules directly by mentioning
pip install modulename (or) sudo pip install modulename
in terminal or command prompt.
But in windows we should mention location of python folder in c directory like c:\python3 and later we should use
pip install modulename
in command prompt or terminal.
or
go n check whether numpy module is installed in sitepackages of python 3 folder in c directory or not.
Support for Python 3 was added in NumPy version 1.5.0, so to begin with, you must download/install a newer version of NumPy.
or use this command to install numpy. This will install the latest version of numpy.
pip install numpy
Winpython has two size, and the smallest "Zero" size doesn't include numpy

Error in creating LMDB database file in Python for Caffe

I'm trying to create an LMDB data base file in Python to be used with Caffe according to this tutorial. The commands import numpy as np and import caffe run perfectly fine. However, when I try to run import lmdb and import deepdish as dd, I'm getting the following errors:
>>> import lmdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named lmdb
>>> import deepdish as dd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named deepdish
I'm running Python 2.7.9 through Anaconda 2.2.0 (64-bit) on Ubuntu 14.04. While installing the dependencies for Caffe according to this page, I've already installed the lmdb package through sudo apt-get install liblmdb-dev.
Any ideas why this error might be occuring?
Well, the apt-get install liblmdb-dev might work with bash (in the terminal) but apparently it doesn't work with Anaconda Python. I figured Anaconda Python might require it's own module for lmdb and I followed this link. The Python installation for lmdb module can be performed by running the command pip install lmdb in the terminal. And then import lmdb in Python works like a charm!
The above installation commands may require sudo.
If you're using Anaconda, then this can solve your problem (it worked for me):
conda install -c https://conda.binstar.org/dougal lmdb
For Anaconda users, installing python-lmdb package from conda-forge should fix the lmdb import error:
conda install -c conda-forge python-lmdb
This was tested on conda 4.5.11 on an lxc-containerized system running Ubuntu 18.04.
Note that there is a conda package named lmdb (without python-), installable via:
conda install -c conda-forge lmdb
that does not fix the import error.

scikits.audiolab doen't import into python (numpy.dtype)

I have installed (with lots of troubles) scikits.audiolab for making sounds out of data. Now when I type:
import scikits.audiolab I get the following error
>>> import scikits.audiolab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/scikits.audiolab-0.11.0-py2.7-macosx-10.7-intel.egg/scikits/audiolab/__init__.py", line 25, in <module>
from pysndfile import formatinfo, sndfile
File "/Library/Python/2.7/site-packages/scikits.audiolab-0.11.0-py2.7-macosx-10.7-intel.egg/scikits/audiolab/pysndfile/__init__.py", line 1, in <module>
from _sndfile import Sndfile, Format, available_file_formats, \
File "numpy.pxd", line 30, in scikits.audiolab.pysndfile._sndfile (/private/tmp/easy_install-gKE3i5/scikits.audiolab-0.11.0/scikits/audiolab/pysndfile/_sndfile.c:9632)
ValueError: numpy.dtype does not appear to be the correct type object
How do I fix this?
Any alternative package that can do the job?
I had the same issue and for me it was caused by installing another (more recent) version of NumPy.
Check if you have different versions of NumPy installed and try switching back to an older one. For my part: I had a system-wide installation of Python and common modules like NumPy, which I couldn't touch because I'm not admin on that system. So when I installed some other library locally (in ~/.local/lib/python2.7/) it would also install more recent versions of SciPy and NumPy and put them into that local folder. And when importing the module it would draw from the local directory first before looking at the system-wide libraries which were working fine before with scikits.audiolab. So for me it was solved by
pip uninstall numy && pip uninstall scipy because that only deleted the newer local versions of numpy.
But more specific to your case, here is a tutorial how (on a Mac) to switch to a certain version of NumPy:
multiple numpy version on Mac OS X
The NumPy version I found working for my scikits.audiolab is 1.6.1
>>> import numpy
>>> numpy.version.version
'1.6.1'
Hope that helps. :)
Maybe you installed/upgraded numpy after installing talkbox. Try running this command:
pip install --upgrade --force-reinstall scikits.talkbox
As suggested here:
https://github.com/ppwwyyxx/speaker-recognition/issues/13

Categories

Resources