I just installed python xy 2.7.9 on Windows 7. I went to run some previously written code in Spyder which calls:
from scipy.sparse import linalg as sla
However, I get the following error:
File "C:\Python27\lib\site-packages\scipy\sparse\linalg\__init__.py", line 113, in <module>
from .matfuncs import *
File "C:\Python27\lib\site-packages\scipy\sparse\linalg\matfuncs.py", line 20, in <module>
import scipy.misc
File "C:\Python27\lib\site-packages\scipy\misc\__init__.py", line 44, in <module>
from . import doccer
ImportError: cannot import name doccer
Does anyone know how to fix this? I find this weird because it worked with my previous copy of Python (which I uninstalled before installing the new version).
Thanks!
What worked for me is moving doccer.py from "misc" folder to "_lib" folder (which are in path /usr/lib/python3/dist-packages/scipy/ for me).
I found this in a release note of scipy : https://github.com/scipy/scipy/pull/9652
Related
I have a question about using numpy library.
A couple of months ago, I downloaded Anaconda, which gives numpy automatically.
I am trying to use numpy by importing from ANaconda to Python.
WHat I have done is:
I added the package of numpy from Anaconda folder to Python folder.
However, the python shell says that
File "C:\Users\Alice Jun\Desktop\Python 3.9\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "C:\Users\Alice Jun\Desktop\Python 3.9\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "C:\Users\Alice Jun\Desktop\Python 3.9\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Alice Jun\Desktop\Python 3.9\gui.py", line 2, in <module>
import numpy as np
File "C:\Users\Alice Jun\Desktop\Python 3.9\numpy\__init__.py", line 140, in <module>
from . import core
File "C:\Users\Alice Jun\Desktop\Python 3.9\numpy\core\__init__.py", line 48, in <module>
raise ImportError(msg)
What should I do to import numpy?
Thank you and stay safe!
As others mentioned, that is not a proper way of installing a package. You are making a copy anyway, so install it through proper routes, e.g.,
# where `python` is the one you wish to use
python -m pip install numpy
Otherwise, the reason why what OP shows did not work is because packages are located under a site-packages directory (search under your Python 3.9/ directory. If one really wants to manually install a package, that's where it goes.
However, be aware that Conda packages make heavy use of dynamic linking in order to minimize redundancy of common dependencies. This is often done through #rpath specifications, which means moving packages out of their Conda environment path will frequently result in non-functionality.
When I use pycharm to run my code with from scipy import stats:
Importerror occurs: DLL load failed: The specified procedure could not be found.
Platform: Anaconda, python 3.7
IDE: pycharm, Microsoft VS code
Anaconda is installed in D:\Anaconda
The scipy package is installed properly. The code can be run successfully in Jupyter.
I have tried the similar questions, but no one can help. Can anybody give me some help to fix it?
I have also reinstalled Anaconda, however, it still faied.
From scipy import stats:
Traceback (most recent call last): ...from scipy import stats File
"D:\Anaconda3\lib\site-packages\scipy\stats__init__.py", line 345, in
from .stats import * File "D:\Anaconda3\lib\site-packages\scipy\stats\stats.py", line 171, in
from . import distributions File "D:\Anaconda3\lib\site-packages\scipy\stats\distributions.py", line
10, in
from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous, File
"D:\Anaconda3\lib\site-packages\scipy\stats_distn_infrastructure.py",
line 24, in
from scipy import optimize File "D:\Anaconda3\lib\site-packages\scipy\optimize__init__.py", line 271,
in
from ._minimize import * File "D:\Anaconda3\lib\site-packages\scipy\optimize_minimize.py", line 21,
in
from scipy.sparse.linalg import LinearOperator File "D:\Anaconda3\lib\site-packages\scipy\sparse\linalg__init__.py", line
117, in
from .eigen import * File "D:\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen__init__.py",
line 11, in
from .arpack import * File "D:\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack__init__.py",
line 22, in
from .arpack import * File "D:\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py",
line 45, in
from . import _arpack ImportError: DLL load failed: The specified procedure could not be found.
enter image description here
I solved it!
I think there must be something wrong in Scipy packages in Conda, so I remove all the packages related to Ski-learn, and download from "https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy".
Choose numpy+whl Scipy ski-learn(corresponding edition) after downloading and install it by pip.
Using the following code
import numpy as np
from scipy.signal import fftconvolve
import matplotlib.pyplot as plt
gives the following stack trace
Traceback (most recent call last):
File "/Users/Erik/Documents/workspace-
python/src/pywavelets/Problem1/Problem1.py", line 8, in <module>
from scipy.signal import fftconvolve
File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/signal/__init__.py", line 311, in <module>
from . import sigtools, windows
File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/signal/windows/__init__.py", line 40, in <module>
from .windows import *
File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/signal/windows/windows.py", line 9, in <module>
from scipy import fftpack, linalg, special
File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/fftpack/__init__.py", line 99, in <module>
from .basic import *
File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/fftpack/basic.py", line 12, in <module>
from . import _fftpack
ImportError:
dlopen(/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/fftpack/_fftpack.cpython-36m-darwin.so, 2): Symbol not
found: _main
Referenced from:
/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/fftpack/_fftpack.cpython-36m-darwin.so
Expected in: flat namespace
in /Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/fftpack/_fftpack.cpython-36m-darwin.so
I've tried reinstalling numpy and scipy using pip, but didn't do anything.
Perhaps I need to specify some library in PYTHONPATH? I've read elsewhere that PyDev should automatically detect necessary imports, and numpy and tensorflow seem to work fine without any outside directories specified.
I do know that the error is specific to PyDev, since the code executes fine in the console.
Can anyone help me pinpoint the problem? Thank you!
If it works in the console an not in PyDev, please check if your environment variables are the same in both cases.
i.e.:
for key, val in sorted(os.environ.items()):
print('%s=%s' % (key, val))
Run both and save the output in different files and then compare to see what's different. The most likely culprits are LD_LIBRARY_PATH, PATH and PYTHONPATH...
One thing to check is running Eclipse from the same console where you got things running (as it should inherit those variables).
I'm going to preface this by saying that I'm relatively new to Python and so please forgive me if I have difficulty understanding something.
I've recently been trying to install OpenCV on my computer following the "Installing OpenCV from prebuilt binaries" instructions found here:
http://docs.opencv.org/3.1.0/d5/de5/tutorial_py_setup_in_windows.html#gsc.tab=0
I initially tried to install OpenCV by itself, as I already had Python 3.5 and a working version of numpy. However, my attempts to import cv2 failed, and I eventually decided to uninstall Python and follow all the steps listed on the website. However, I now have this error when I try import numpy:
Traceback (most recent call last):
File "C:/PythonProgramming/SLIC/src/SLICAlgorithm.py", line 1, in <module>
import numpy
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 180, in <module>
from . import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 20, in <module>
import function_base
File "C:\Python27\lib\site-packages\numpy\core\function_base.py", line 6, in <module>
from .numeric import result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, TooHardError
ImportError: cannot import name shares_memory
Process finished with exit code 1
Other people online seem to have no problem with these instructions, or at least not with numpy. What does this error mean, and what can I do to fix it? I have a 64-bit version of Windows 10 and am working in PyCharm. All help you can provide would be much appreciated.
same problem, the following fix worked for me
pip install -I numpy --force-reinstall
I'm trying to run a naive bayes script that needs NumPy, SciPy and Pandas to run. To avoid the confusion with the multiple copies of python on Macs 10.7 --and because I couldn't figure out how to, really - I made a virtualenv and installed NumPy and SciPy there, checking that after running
$ python
>>> import numpy
>>> import scipy
everything works. Now, I'm in my file's directory, and running python nb_predict.py gives me a bunch of errors.
Originally, the path to my python compiler at the top of my file was
#!/usr/local/bin/python
but since I didn't know if it had changed after installing everything in the virtual env, I've tried it with:
#!/Users/myusername/.virtualenvs/scipy/bin/python
and it still doesn't work. I've made the script executable, also.
Please, any help would be greatly appreciated!
This is what I get as the error:
Traceback (most recent call last):
File "nb_predict.py", line 3, in <module>
from sklearn.naive_bayes import MultinomialNB
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scikit_learn-0.15_git-py2.7-macosx-10.9-intel.egg/sklearn/naive_bayes.py", line 25, in <module>
from .preprocessing import binarize
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scikit_learn-0.15_git-py2.7-macosx-10.9-intel.egg/sklearn/preprocessing/__init__.py", line 22, in <module>
from .imputation import Imputer
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scikit_learn-0.15_git-py2.7-macosx-10.9-intel.egg/sklearn/preprocessing/imputation.py", line 10, in <module>
from scipy import stats
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/stats/__init__.py", line 332, in <module> from .stats import *
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/stats/stats.py", line 181, in <module>
import scipy.special as special
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/special/__init__.py", line 532, in <module>
from ._ufuncs import *
ImportError: dlopen(/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/special/_ufuncs.so, 2): Symbol not found: ___sincos_stret
Referenced from: /Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/special/_ufuncs.so
Expected in: /usr/lib/libSystem.B.dylib
in /Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/special/_ufuncs.so