简体   繁体   English

Mac - 没有名为“scipy”的模块

[英]Mac - No module named 'scipy'

I've tried everything but can't get Scipy to work.我已经尝试了一切,但无法让 Scipy 工作。

Installed Scipy via Homebrew, seemed to work fine - but then the error when trying to import it.通过 Homebrew 安装 Scipy,似乎工作正常 - 但是尝试导入它时出现错误。 Uninstalled, installed via pip3, no difference.卸载,通过pip3安装,没有区别。 Brew doctored, brew link (forced links for the unlinked kegs for Scipy AND python), no progress.酿造篡改,酿造链接(Scipy 和 python 的未链接小桶的强制链接),没有进展。

Running on macOS Mojave (10.14.6).在 macOS Mojave (10.14.6) 上运行。 Numpy, matplotlib and much more is working fine. Numpy、matplotlib 和更多工作正常。 What am I missing here?我在这里想念什么?

I have two versions of python installed, but Scipy SHOULD be installed in python3.7 (which I am using).我安装了两个版本的 python,但 Scipy 应该安装在 python3.7(我正在使用)中。 See more below:见下文:

d37072:~ au341374$ brew info scipy
scipy: stable 1.3.0 (bottled), HEAD
Software for mathematics, science, and engineering
https://www.scipy.org
/usr/local/Cellar/scipy/1.3.0_1 (962 files, 47.3MB) *
  Poured from bottle on 2019-09-20 at 03:39:57
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/scipy.rb
==> Dependencies
Build: swig ✔
Required: gcc ✔, numpy ✔, openblas ✔, python ✔
==> Options
--HEAD
    Install HEAD version
'import sitecustomize' failed; use -v for traceback
'import sitecustomize' failed; use -v for traceback
==> Caveats
If you use system python (that comes - depending on the OS X version -
with older versions of numpy, scipy and matplotlib), you may need to
ensure that the brewed packages come earlier in Python's sys.path with:
  mkdir -p /Users/au341374/Library/Python/2.7/lib/python/site-packages
  echo 'import sys; sys.path.insert(1, "/usr/local/lib/python3.7/site-packages")' >> /Users/au341374/Library/Python/2.7/lib/python/site-packages/homebrew.pth
==> Analytics
install: 3,010 (30 days), 5,751 (90 days), 31,101 (365 days)
install_on_request: 2,070 (30 days), 3,613 (90 days), 19,312 (365 days)
build_error: 0 (30 days)

- -

d37072:~ au341374$ pip3 install scipy
Requirement already satisfied: scipy in /usr/local/lib/python3.7/site-packages (1.3.1)
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.7/site-packages (from scipy) (1.16.4)


d37072:~ au341374$ brew install scipy
Warning: scipy 1.3.0_1 is already installed and up-to-date
To reinstall 1.3.0_1, run `brew reinstall scipy`

- -

d37072:~ au341374$ brew link scipy
Warning: Already linked: /usr/local/Cellar/scipy/1.3.0_1
To relink: brew unlink scipy && brew link scipy


d37072:~ au341374$ brew link python
Warning: Already linked: /usr/local/Cellar/python/3.7.4_1
To relink: brew unlink python && brew link python

- -

d37072:~ au341374$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config
  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config
  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config
  /usr/local/munki/munkiwebadmin-config

- -

d37072:~ au341374$ which -a python
/usr/local/bin/python
/usr/bin/python

d37072:~ au341374$ which -a pip
/usr/local/bin/pip

d37072:~ au341374$ which -a python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
/usr/local/bin/python3

d37072:~ au341374$ which -a pip3
/usr/local/bin/pip3

- -

d37072:~ au341374$ pip -V
'import sitecustomize' failed; use -v for traceback
pip 19.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 2.7)

d37072:~ au341374$ pip3 -V
pip 19.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

Well, somehow inadvertently fixed it.好吧,不知何故无意中修复了它。 I un- and reinstalled numpy and scipy a few times to no avail.我卸载并重新安装了几次 numpy 和 scipy 无济于事。 Finally uninstalled numpy, scipy, matplotlib, ipython and jupyter so that it would let me uninstall python.最后卸载了 numpy、scipy、matplotlib、ipython 和 jupyter,这样我就可以卸载 Z23EEEB7947BDD7556BDDA6。 Reinstalling python numpy and scipy fixed nothing.重新安装 python numpy 和 scipy 没有解决任何问题。 Then, after running然后,运行后

pip3 install --user numpy scipy matplotlib ipython jupyter pandas sympy nose

I think this did it.我认为这做到了。 Scipy and numpy are now apparently installed in Scipy 和 numpy 现在显然安装在

scipy in ./Library/Python/3.7/lib/python/site-packages (1.3.1)
numpy>=1.13.3 in ./Library/Python/3.7/lib/python/site-packages (from scipy) (1.17.2)

Rather than in usr/local/lib/Python3.7/site-packages where a regular "pip3 install scipy" was installing it.而不是在常规“pip3 install scipy”安装它的 usr/local/lib/Python3.7/site-packages 中。

Now the only weird thing is that./Library/Python/ only actually contains a folder called 2.7 and not 3.7 (no hidden folders).现在唯一奇怪的是 ./Library/Python/ 实际上只包含一个名为 2.7 而不是 3.7 的文件夹(没有隐藏文件夹)。 I'm weirded out, but hey, it works.我很奇怪,但是,嘿,它有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM