I am new and trying to contribute to scipy development. I forked scipy in my github and tried to build it based on this documentation. However, while trying to import scipy in Python, I get the following error:
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scipy
I also have tried installing all the necessary pre-requirements as mentioned here. I know I can do pip install scipy, but that's not the point of building the developer version of scipy, I guess. Can someone help?
I found this issue: https://github.com/scipy/scipy/issues/5893 which suggest to add scipy in your PYTHONPATH: export PYTHONPATH="$HOME/path/to/scipy/:$PYTHONPATH"
More info on how to do this per different system from scipy documentation (FAQ section):
On Linux and OSX, you can run the command:
$ export PYTHONPATH=$PWD
and on Windows
$ set PYTHONPATH=/path/to/scipy
Another workaround is also suggested in the before-mentioned issue, which is to open the scipy build as a PyCharm project and create a virtual environment within the IDE to use for your coding!
Good luck :)
Related
I'm rather new to coding, so please bare with me if I'm not using the optimal terminology to ask this question. I've installed and set up python on my Mac using pyenv based on the following link:
https://opensource.com/article/19/5/python-3-default-mac
I'm currently trying to execute a program, but I receive a ModuleNotFoundError on Numpy upon execution.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
ModuleNotFoundError: No module named 'numpy'
I've checked via terminal and ensured numpy is installed, I went through the pyenv source files and confirmed numpy is there, and tried the "python -mpip install numpy" method to no avail. I'm not sure what to do at this point, so any of your suggestions would be greatly appreciated! Thank you!
I'm trying to install NUMBA on a mac machine (10.12.6).
I've tried with CONDA:
conda install numba
I'm getting this:
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /Users/lefaa/miniconda2:
#numba 0.35.0 np113py27_6
This seems good, however when I try (using python 2.7):
python -c "from numba import jit"
I'm getting that the numba module isn't installed:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named numba
Do I have to configure something else?
It is likely that your path is not set up correctly and the python that conda installed numba into is not the one you are running. If you run which python you should get the one that's in your miniconda2 if everything is working properly. If you get a different python executable then you probably need to set your PATH environment variable. See:
https://conda.io/docs/user-guide/install/index.html#installing-conda-on-a-system-that-has-other-python-installations-or-packages
I solved the issue. Indeed, when installing with conda, conda installs the target package in python associated to conda (i.e, in this python '/Users/lefaa/miniconda2/bin/python'). So to import numba, it is necessary to lunch the python of miniconda.
However, to install numba on the main python (python2.7), one solution will be to install like this '/usr/local/bin/pip2.7 install numba'.
I used python xy recently with an old lib of scipy (0.15). Because I wanted to use Spherical Voronoi, I had to install a more recent version of scipy. For this I used pip and the unofficial distributions for python modules with wheel. The install worked without error messages. But now, if I try to import scipy by code, I get this error message below. I already unistalled whole python packages so far and instead installed anaconda. But the error message is still the same. I checked my registry (Windows 10) - can't find anything suspicious.
Any idea? Thank you!
test.py
1.12.1
Traceback (most recent call last):
File "test.py", line 11, in <module>
import scipy
File "C:\Users\Boss\AppData\Roaming\Python\Python27\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name NUMPY_MKL
Your scipy is built with mkl support and requires mkl support in numpy too. Download numpy from the same site you downloaded scipy (probably Christoph Gohlke's builds). Or if you are using Anaconda use Anaconda packages for both.
Updated - Your error is basically that numpy+mkl (numpy with Intel math Kernel library) so this is because when you have installed the scipy by precompiled archive, which requires numpy+mkl but installing numpy using pip won't get you that.
This problem can be easy solved by installation for numpy+mkl from whl file from - http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Old - This is due to the improper installation of numpy, I've had this error few days ago and then I had to install the numpy again. So, upgrade pip and then try installing the numpy whl again. It just worked for me.
Get it here -https://pypi.python.org/pypi/numpy
even this has almost everything - http://www.lfd.uci.edu/~gohlke/pythonlibs/
I am currently following a beginners introduction to machine learning.
While entering in the command:
import pandas as pd in the python shell in terminal, I get an error reading:
ImportError: Missing required dependencies ['numpy'].
I already looked at the other similar question, tried that solution, but still received the same error.
Looks like you might be running on a Mac and perhaps using the default system python. For whatever reason you don't have a complete installation. you have pandas but not numpy. I'm not sure which packages the tutorial you are following uses, but I would recommend installing the Anaconda python distribution as it includes pandas, all its dependencies and much more, including the scikit-learn package often used for machine learning.
If you want to know more about installing a Python environment for machine learning on a Mac, there is a good tutorial on machinelearningmastery.com.
This doesn't have anything to do with incompatibility. As #Peter mentioned, you simply don't have NumPy and should install through Anaconda. Here is the code within pandas that is giving you the error:
# Let users know if they're missing any of our hard dependencies
hard_dependencies = ("numpy", "pytz", "dateutil")
missing_dependencies = []
for dependency in hard_dependencies:
try:
__import__(dependency)
except ImportError as e:
missing_dependencies.append(dependency)
if missing_dependencies:
raise ImportError("Missing required dependencies {0}".format(missing_dependencies))
del hard_dependencies, dependency, missing_dependencies
Notice there is nothing here about version.
I had a same problem. I don't know what is the cause of the problem, but it seems to deal with how numpy is installed. You can try the following:
Install pandas
Uninstall numpy
Download numpy whl for your needs from here
Install numpy from downloaded whl
That worked for me!
I get the same error message with my Anaconda installation when I forget to activate the environment:
Testcode: import_pandas.py:
import pandas
print('Pandas import succeeded!')
Run import_pandas.py with ImportError:
Microsoft Windows [Version 10.0.16299.1146]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Users\peter\demo>python import_pandas.py
Traceback (most recent call last):
File "import_pandas.py", line 1, in <module>
import pandas
File "C:\Users\peter\AppData\Local\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
However, after activating conda everything works perfectly fine:
C:\Users\peter\demo>activate
C:\Users\peter\demo>conda.bat activate
(base) C:\Users\peter\demo>python import_pandas.py
Pandas import succeeded!
This is the error I get when trying to import numpy on opening python (2.7.8):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
This is the path of my python binary /usr/local/bin/python
This is the path of pip /usr/local/bin/pip
Also, when I put in pip freeze I found the numpy package numpy==1.8.0rc1
I have looked at other relevant questions, but I'm not able to diagnose the cause. I'm guessing it might be some problem in PATHS. Where do I start?
As Akshat pointed out in the comments above, I had multiple versions of Python installed. This could have been the effect of using homebrew and/or macports in the past. I followed the steps detailed in Too many pythons on my Mac OS X Mountain Lion
and did a fresh install of Python 2.7.12 I was then able to reinstall pip and the packages subsequently.