sicpy版本不对,卸载其他版本,安装1.2.1版
1,查看现有版本
$ pip3.6 list
2,卸载现有版本
$ pip3.6 uninstall scipy
3,安装指定岸本
$ pip3.6 --trusted-host=files.pythonhosted.org --trusted-host=pypi.org install scipy==1.2.1 --user
参考:https://blog.csdn.net/WUDIxi/article/details/100060055
如果还是不对,你可以尝试加一行import : from scipy.ndimage import filters
$ python3.6
Python 3.6.9 (default, Jul 3 2019, 15:36:16)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> a = numpy.array([1,4,6,8,7,8,]).reshape((2, 3))>>> import scipy
>>> scipy.misc.imresize(a, size=(60, 60), interp='bilinear')
Traceback (most recent call last):File "<stdin>", line 1, in <module>
AttributeError: module 'scipy' has no attribute 'misc'>>> from scipy.ndimage import filters
>>> scipy.misc.imresize(a, size=(60, 60), interp='bilinear')
array([[ 0, 0, 0, ..., 182, 182, 182],[ 0, 0, 0, ..., 182, 182, 182],[ 0, 0, 0, ..., 182, 182, 182],...,[255, 255, 255, ..., 255, 255, 255],[255, 255, 255, ..., 255, 255, 255],[255, 255, 255, ..., 255, 255, 255]], dtype=uint8)
至于具体为什么能work,还没有特别调查清楚。
注:scipy安装报错
$ sudo pip install scipy==1.2.1
WARNING: The directory '/home/xxx/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting scipy==1.2.1Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a9/b4/5598a706697d1e2929eaf7fe68898ef4bea76e4950b9efbe1ef396b8813a/scipy-1.2.1.tar.gz (23.1 MB)|████████████████████████████████| 23.1 MB 29 kB/s
Installing collected packages: scipyRunning setup.py install for scipy ... errorERROR: Command errored out with exit status 1:command: /usr/local/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0xfe8ppi/scipy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0xfe8ppi/scipy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-x49l1nik/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/scipycwd: /tmp/pip-install-0xfe8ppi/scipy/Complete output (113 lines):Note: if you need reliable uninstall behavior, then installwith pip instead of using `setup.py install`:- `pip install .` (from a git repo or downloaded sourcerelease)- `pip install scipy` (last SciPy release on PyPI)Running from scipy source directory.lapack_opt_info:lapack_mkl_info:customize UnixCCompilerlibraries mkl_rt not found in ['/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/x86_64-linux-gnu']NOT AVAILABLEopenblas_lapack_info:libraries openblas not found in ['/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/x86_64-linux-gnu']NOT AVAILABLEopenblas_clapack_info:libraries openblas,lapack not found in ['/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/x86_64-linux-gnu']NOT AVAILABLEflame_info:libraries flame not found in ['/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/x86_64-linux-gnu']NOT AVAILABLEatlas_3_10_threads_info:Setting PTATLAS=ATLASlibraries lapack_atlas not found in /usr/local/liblibraries tatlas,tatlas not found in /usr/local/liblibraries lapack_atlas not found in /usr/lib64libraries tatlas,tatlas not found in /usr/lib64libraries lapack_atlas not found in /usr/liblibraries tatlas,tatlas not found in /usr/liblibraries lapack_atlas not found in /usr/lib/x86_64-linux-gnulibraries tatlas,tatlas not found in /usr/lib/x86_64-linux-gnu<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>NOT AVAILABLEatlas_3_10_info:libraries lapack_atlas not found in /usr/local/liblibraries satlas,satlas not found in /usr/local/liblibraries lapack_atlas not found in /usr/lib64libraries satlas,satlas not found in /usr/lib64libraries lapack_atlas not found in /usr/liblibraries satlas,satlas not found in /usr/liblibraries lapack_atlas not found in /usr/lib/x86_64-linux-gnulibraries satlas,satlas not found in /usr/lib/x86_64-linux-gnu<class 'numpy.distutils.system_info.atlas_3_10_info'>NOT AVAILABLEatlas_threads_info:Setting PTATLAS=ATLASlibraries lapack_atlas not found in /usr/local/liblibraries ptf77blas,ptcblas,atlas not found in /usr/local/liblibraries lapack_atlas not found in /usr/lib64libraries ptf77blas,ptcblas,atlas not found in /usr/lib64libraries lapack_atlas not found in /usr/liblibraries ptf77blas,ptcblas,atlas not found in /usr/liblibraries lapack_atlas not found in /usr/lib/x86_64-linux-gnulibraries ptf77blas,ptcblas,atlas not found in /usr/lib/x86_64-linux-gnu<class 'numpy.distutils.system_info.atlas_threads_info'>NOT AVAILABLEatlas_info:libraries lapack_atlas not found in /usr/local/liblibraries f77blas,cblas,atlas not found in /usr/local/liblibraries lapack_atlas not found in /usr/lib64libraries f77blas,cblas,atlas not found in /usr/lib64libraries lapack_atlas not found in /usr/liblibraries f77blas,cblas,atlas not found in /usr/liblibraries lapack_atlas not found in /usr/lib/x86_64-linux-gnulibraries f77blas,cblas,atlas not found in /usr/lib/x86_64-linux-gnu<class 'numpy.distutils.system_info.atlas_info'>NOT AVAILABLEaccelerate_info:NOT AVAILABLElapack_info:libraries lapack not found in ['/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/x86_64-linux-gnu']NOT AVAILABLE/usr/local/lib/python3.8/site-packages/numpy/distutils/system_info.py:1730: UserWarning:Lapack (http://www.netlib.org/lapack/) libraries not found.Directories to search for the libraries can be specified in thenumpy/distutils/site.cfg file (section [lapack]) or by settingthe LAPACK environment variable.return getattr(self, '_calc_info_{}'.format(name))()lapack_src_info:NOT AVAILABLE/usr/local/lib/python3.8/site-packages/numpy/distutils/system_info.py:1730: UserWarning:Lapack (http://www.netlib.org/lapack/) sources not found.Directories to search for the sources can be specified in thenumpy/distutils/site.cfg file (section [lapack_src]) or by settingthe LAPACK_SRC environment variable.return getattr(self, '_calc_info_{}'.format(name))()NOT AVAILABLETraceback (most recent call last):File "<string>", line 1, in <module>File "/tmp/pip-install-0xfe8ppi/scipy/setup.py", line 492, in <module>setup_package()File "/tmp/pip-install-0xfe8ppi/scipy/setup.py", line 488, in setup_packagesetup(**metadata)File "/usr/local/lib/python3.8/site-packages/numpy/distutils/core.py", line 137, in setupconfig = configuration()File "/tmp/pip-install-0xfe8ppi/scipy/setup.py", line 395, in configurationraise NotFoundError(msg)numpy.distutils.system_info.NotFoundError: No lapack/blas resources found.----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0xfe8ppi/scipy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0xfe8ppi/scipy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-x49l1nik/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/scipy Check the logs for full command output.
解决方法:
sudo apt-get install gfortran libopenblas-dev liblapack-dev
sudo pip install scipy==1.2.1
感谢 Peter Mortensen @ https://stackoverflow.com/questions/7496547/does-python-scipy-need-blas
代码段 小部件
[Dàimǎ duàn xiǎo bùjiàn]
Snippet widget