已安装scipy,但导入scipy失败,请导入numpy,好

时间:2019-12-21 21:22:47

标签: python numpy scipy cygwin mingw

我需要错误功能,所以我尝试安装scipy。我相信我已经安装了numpy和scipy。我可以使用numpy很好。例如:

>>>import numpy
>>>import scipy
Traceback (most recent call last): 
 File "<stdin>", line 1 in <module>
ModuleNotFoundError: No module named 'scipy'

如果我执行>>>import scipy.special,则会得到相同的结果。如果我尝试安装scipy,它会告诉我它已经安装了。如果我强制安装 $pip install --user --force-reinstall scipy我得到以下信息:

Collecting scipy
  Using cached https://files.pythonhosted.org/packages/61/51/046cbc61c7607e5ecead6ff1a9453fba5e7e47a5ea8d608cc7036586a5ef/scipy-1.4.1-cp37-cp37m-win_amd64.whl
Collecting numpy>=1.13.3 (from scipy)
  Using cached https://files.pythonhosted.org/packages/34/40/c6eae19892551ff91bdb15f884fef2d42d6f58da55ab18fa540851b48a32/numpy-1.17.4-cp37-cp37m-win_amd64.whl
Installing collected packages: numpy, scipy
  Found existing installation: numpy 1.17.4
    Uninstalling numpy-1.17.4:
      Successfully uninstalled numpy-1.17.4
  WARNING: The script f2py.exe is installed in 'C:\Users\Larry\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  Found existing installation: scipy 1.4.1
    Uninstalling scipy-1.4.1:
      Successfully uninstalled scipy-1.4.1
Successfully installed numpy-1.17.4 scipy-1.4.1
WARNING: You are using pip version 19.1.1, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command

它似乎安装得很好。那我为什么不能使用它呢?我在Cygwin工作。我在Windows下安装和使用scipy完全没有问题。肯定有些简单的事情我做错了。我希望有人能告诉我这是什么。拜托。


更新19/12/22 更多细节。我已经在计算机上安装了Cygwin几年了。我不确定何时获得cygwin版本的Python和numpy。我安装了mingw和python 7/5/19。然后我意识到我需要错误功能,因此我尝试使用pip在两者上安装scipy。我小心地在c:/ mingw中安装mingw,在c:/ cwin中安装cygwin,以确保它是分开的。点子似乎并不十分小心。我之前发布了f2py的问题-f2py linking quadmath libraries? Use ctypes for fortran wrapper instead?。可能与此有关。

这是我现在拥有的:

由cygwin提示符下的pip安装(请参见上面的输出):12/21/19:

    C:\Users\Larry\AppData\Roaming\Python\Python37\Scripts\site-packages\scipy & \numpy

Windows / mingw安装了numpy 7/5/19,scipy通过pip 8/2/19安装了:

    C:\program files\python37\lib\site-packages\scipy & numpy

由Cygwin安装6/27/2019

    C:\cwin\usr\python3.6\site-packages\numpy but no scipy

无法访问cygwin提示符下通过pip安装的版本(在漫游中)。我没有更改路径,而是将它们移至cygwin目录,并尝试从cygwin执行它们。我收到消息:

>>> import scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/scipy/__init__.py", line 63, in <module>
    from numpy import show_config as show_numpy_config
  File "/usr/lib/python3.6/site-packages/numpy/__init__.py", line 140, in <module>
    from . import _distributor_init
  File "/usr/lib/python3.6/site-packages/numpy/_distributor_init.py", line 9, in <module>
    from ctypes import WinDLL
ImportError: cannot import name 'WinDLL'

即使我是从cygwin提示符下安装的,这些也必须是Windows版本。点子似乎不能很好地工作。我需要其他安装方法。有人可以建议吗????

0 个答案:

没有答案