【发布时间】:2021-09-18 09:56:49
【问题描述】:
我买了一台 MacBook Pro 13 M1(16 GB RAM,1 TB SSD),我正在尝试设置它以供工作,其中一部分是使用 python 2(是的,我知道它已经报废了,我仍然需要使用它,直到我们完成移植去)。我有一些我想从我的系统 python2 中删除的 python 包(我确定我必须在某个时候在这些上运行 sudo pip install ,我知道这很愚蠢,但是已经完成了)现在我在 Big Sur 我无法删除这些包裹。我尝试禁用 SIP,直到我可以将它们删除(csrutil disable 从恢复中),但现在我收到错误,我无法从只读文件系统中删除文件
sudo pip uninstall cryptography 2 14:34
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
WARNING: The directory '/Users/darren/Library/Caches/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.
Found existing installation: cryptography 3.3.2
Uninstalling cryptography-3.3.2:
Would remove:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography-3.3.2-py2.7.egg-info
Proceed (y/n)? y
ERROR: Exception:
Traceback (most recent call last):
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
status = self.run(options, args)
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/pip/_internal/commands/uninstall.py", line 90, in run
auto_confirm=options.yes, verbose=self.verbosity > 0,
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/pip/_internal/req/req_install.py", line 686, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/pip/_internal/req/req_uninstall.py", line 403, in remove
moved.stash(path)
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/pip/_internal/req/req_uninstall.py", line 292, in stash
renames(path, new_path)
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/pip/_internal/utils/misc.py", line 355, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 323, in move
rmtree(src)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 270, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 275, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 273, in rmtree
os.remove(fullname)
OSError: [Errno 30] Read-only file system: '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/hazmat/_der.py'
但我无法将 root 重新挂载为读/写,并在尝试时收到此错误:
sudo mount -uw /
mount_apfs: volume could not be mounted: Permission denied
mount: / failed with 66
如果 /System/Library 是只读的,如何从这些文件中删除这些文件?既然 mac os 将这些文件放在只读文件系统中,我是否必须格式化我的系统并从头开始,还是有办法删除它们?
编辑:
所以我在 /System/Library 中破坏了阻止结构运行的包,因此我无法启动和运行我们的东西。主要的是密码学包。所以我要么需要修复这些包,以便fabric 可以运行或删除它们或其他东西。
让这变得如此痛苦的另一部分是我试图在 M1 Mac 上运行 python 2,这意味着要么使用内置的 python,要么使用带有 x86 python2 的 Rosetta,因为我没有找到安装 arm 的方法M1 Mac 上的 python 2(没有来自 python.org 或 brew 的安装程序,因为在 M1 Mac 发货时,python2 已经结束)。
编辑2:
也许我遇到问题的这些软件包确实随 Mac OS 一起提供,因为软件包文件夹的创建时间戳是“Jan 1 01:00:00 2020”,就像同一文件夹中的所有其他文件和文件夹一样。如果是这样,我想我需要以某种方式修复它们。当我尝试从命令行运行 fab 时,我在加密包中收到此错误:
fab
/Users/darren/Library/Python/2.7/lib/python/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography.hazmat.backends import default_backend
Traceback (most recent call last):
File "/Users/darren/Library/Python/2.7/bin/fab", line 5, in <module>
from fabric.main import program
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/fabric/__init__.py", line 3, in <module>
from .connection import Config, Connection
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/fabric/connection.py", line 16, in <module>
from paramiko.agent import AgentRequestHandler
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/paramiko/__init__.py", line 22, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/paramiko/transport.py", line 129, in <module>
class Transport(threading.Thread, ClosingContextManager):
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/paramiko/transport.py", line 190, in Transport
if KexCurve25519.is_available():
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/paramiko/kex_curve25519.py", line 30, in is_available
X25519PrivateKey.generate()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/hazmat/primitives/asymmetric/x25519.py", line 39, in generate
from cryptography.hazmat.backends.openssl.backend import backend
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/hazmat/backends/openssl/backend.py", line 117, in <module>
from cryptography.hazmat.bindings.openssl import binding
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/hazmat/bindings/openssl/binding.py", line 14, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: dlopen(/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/hazmat/bindings/_openssl.so, 2): Symbol not found: _DTLS_client_method
Referenced from: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/hazmat/bindings/_openssl.so
Expected in: flat namespace
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/paramiko/transport.py", line 120, in _join_lingering_threads
for thr in _active_threads:
TypeError: 'NoneType' object is not iterable
Error in sys.exitfunc:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/Users/darren/Library/Python/2.7/lib/python/site-packages/paramiko/transport.py", line 120, in _join_lingering_threads
for thr in _active_threads:
TypeError: 'NoneType' object is not iterable
有其他人遇到过这个问题或有解决方法吗?
【问题讨论】:
-
你不能,也不应该,也不应该。 不要删除这些文件;如果您不想使用此 Python 安装,请停止使用它。请注意,此 Python 安装是 MacOS 本身的一部分,因此如果您重新安装 MacOS,它仍然会存在。如果没有这些文件,您将无法有效安装 Big Sur。
-
请注意,
sudo pip install不能像rm一样更改这些文件。 -
@nobled, ...此外,您完全可以在 M1 上安装不同的 Python 解释器。
brew可能不会这样做,但 Nix 完全会。见stackoverflow.com/questions/65653464/… -
@CharlesDuffy 感谢您的推荐。我以前没有使用或听说过 nix,但我能够通过 nix 安装 python2,然后安装 pip,然后安装密码学,现在 fabric 正在工作!
-
顺便说一句,您可以告诉 Nix 为您安装 Python 模块(如 pip 或密码学)。
python27.withPackages (p: [p.pip p.cryptography]),例如。nix-build -E '((import <nixpkgs> {}).python27.withPackages (p: [p.pip p.cryptography]))'是实际运行它的一种方式。
标签: python macos python-2.7 pip python-cryptography