在MacOS Big Sur 11.3上升级Python 2.7.16库
为了确认一位同事的结果,他使用python2从scipy用Cubicspline编写了一个插值,我必须导入Cubicspline函数。我知道python2不推荐使用,但这只是为了验证 但是当我做一个在MacOS Big Sur 11.3上升级Python 2.7.16库,python,python-2.7,scipy,macos-big-sur,cubic-spline,Python,Python 2.7,Scipy,Macos Big Sur,Cubic Spline,为了确认一位同事的结果,他使用python2从scipy用Cubicspline编写了一个插值,我必须导入Cubicspline函数。我知道python2不推荐使用,但这只是为了验证 但是当我做一个 from scipy.interpolate import CubicSpline 我已收到错误消息: ImportError: cannot import name CubicSpline 因此,我尝试通过以下方式使用pip-2.7安装它: curl https://bootstrap.pyp
from scipy.interpolate import CubicSpline
我已收到错误消息:
ImportError: cannot import name CubicSpline
因此,我尝试通过以下方式使用pip-2.7安装它:
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python2.7 get-pip.py
然后从目录~/Library/Python/2.7/bin
:
./pip2.7 install scipy
但找不到相同的错误,CubicSpline
我有以下版本:
$ which python2.7
/usr/bin/python2.7
因此python2.7是系统的默认python2
如何在操作系统中默认安装的python2.7
上安装CubicSpline
库
我必须重新安装所有的python2.7框架吗?如果是,如何执行
更新1
情况变得更糟:
执行$python2.7-m pip安装scipy numpy之后,我现在得到:
$ python2.7
Python 2.7.16 (v2.7.16:413a49145e, Mar 2 2019, 14:32:10)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(.startup.py)
Traceback (most recent call last):
File "/Users/fab/.startup.py", line 3, in <module>
import numpy as np
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/__init__.py", line 71, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
1. Check that you are using the Python you expect (you're using /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python),
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy versions you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/_multiarray_umath.so, 2): Symbol not found: ___addtf3
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/../.dylibs/libquadmath.0.dylib
Expected in: /usr/lib/libSystem.B.dylib
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/../.dylibs/libquadmath.0.dylib
在Big Sur上,我看到文件libSystem.B.dylib
已经不存在了
如何规避所有这些问题
更新2
情况有所好转,但并非全部完成
我从MacPorts和位于/usr/local/bin/
中的类python2*
的无用二进制文件中删除了python2.7
现在,我只有来自/usr/bin/python2.7
的二进制文件python2.7
:
WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.
Python 2.7.16 (default, Feb 28 2021, 12:34:25)
[GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import scipy
>>> from scipy.interpolate import CubicSpline
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name CubicSpline
>>>
我得到:
>>> scipy.version.version
'0.13.0b1'
Python 2.7.16 (default, Feb 28 2021, 12:34:25)
[GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin
Type "help", "copyright", "credits" or "license" for more information.
(.startup.py)
(imported numpy as np)
(imported matplotlib.pyplot as plt)
(imported scipy.interpolate CubicSpline)
(imported scipy.interpolate interp1d)
(imported os)
(imported sys)
(imported glob)
有没有办法升级MacOS Big Sur Python 2.7默认系统的scipy(我的意思是不使用Brew/Macports)
更新4
我什么都不懂,在类似的MacBook Pro和Big Sur 11.3上,如果我懂:
$ import scipy
scipy.version.version
/usr/bin/python2.7
我得到:
>>> scipy.version.version
'0.13.0b1'
Python 2.7.16 (default, Feb 28 2021, 12:34:25)
[GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin
Type "help", "copyright", "credits" or "license" for more information.
(.startup.py)
(imported numpy as np)
(imported matplotlib.pyplot as plt)
(imported scipy.interpolate CubicSpline)
(imported scipy.interpolate interp1d)
(imported os)
(imported sys)
(imported glob)
如果看看python2.7 shell中的scipy
版本,我会得到:
>>> import scipy
>>> scipy.version.version
'1.2.2'
在哪里安装了Big Sur 11.3
上默认的python 2.7
的numpy
和scipy
库我试图在/System/Library
和~/Library/
,以及/Library/
中查找(使用sudo grep-riIHn cubicspline
),但什么也没有找到。你似乎在问完全相同的问题:请不要交叉发布。@jaume抱歉,我要删除另一个。RegardsIf/usr/lib/libSystem.B.dylib不再可用。您似乎安装了错误版本的numpy(或者在Big Sur上没有一个可以与python2一起使用)。但正如其他人在AD评论中已经提到的:目前未知变量太多,很难提出解决方案。也许解决方案是找到一个文件,强制brew
安装所有python2.7和Librariesnumpy
和scipy
:任何人都可以下载这种文件吗?这样,我就可以做到:brew安装文件\u python2.7\u包