gpt4 book ai didi

AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsArmFramework'(AttributeError:模块‘virtualenv.create.via_global_ref.builtin.cpython.mac_os’没有属性‘CPython2macOsArmFramFrame’)

转载 作者:bug小助手 更新时间:2023-10-25 09:33:11 76 4
gpt4 key购买 nike



I was trying to configure pre-commit hooks and while running pre-commit run --all-files I got this error:

我试图配置预提交挂接,在运行预提交运行--所有文件时,我收到以下错误:


[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/dark_matter88/opt/anaconda3/bin/python3.8', '-mvirtualenv', '/Users/dark_matter88/.cache/pre-commit/repojfgkwtv7/py_env-python3.8')
return code: 1
stdout:
AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsArmFramework'

I've tried to upgrade pip to resolve this issue pip install --upgrade pip and I received another error:

我已尝试升级pip以解决此问题pip安装--升级pip,但我收到另一个错误:


Traceback (most recent call last):
File "/Users/admin/opt/anaconda3/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/Users/admin/.local/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/Users/admin/.local/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/Users/admin/.local/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 9, in <module>
from pip._internal.build_env import get_runnable_pip
File "/Users/admin/.local/lib/python3.8/site-packages/pip/_internal/build_env.py", line 15, in <module>
from pip._vendor.packaging.requirements import Requirement
ModuleNotFoundError: No module named 'pip._vendor.packaging'

I tried to check versions of both pip and pip3, and now I'm also getting the same No module named 'pip._vendor.packaging' error. I've tried all the solutions I could find, but nothing's helped.
I'm thinking if it's related to having several versions of python installed.

我尝试检查PIP和PIP3的版本,但现在我也收到了名为‘pip._vendor.pack’的相同的No模块错误。我试了我能找到的所有解决方案,但都没有用。我在想,这是否与安装了几个版本的Python有关。


更多回答

same error here. This is related to virtualenv. If I just execute virtualenv in bash I get the same error message.

这里也有同样的错误。这与Virtualenv相关。如果我只是在bash中执行Virtualenv,我会得到相同的错误消息。

优秀答案推荐

Got the same error on Python 3.9.2 and virtualenv==20.23.0.

在Python3.9.2和Virtualenv==20.23.0上得到相同的错误。


▶ virtualenv   
AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsFramework'
▶ virtualenv --version
virtualenv 20.23.0 from ~/.local/lib/python3.9/site-packages/virtualenv/__init__.py

For some reason, after I uninstalled virtualenv with pip uninstall virtualenv -y, the server also had v20.4.0 still installed and this version worked without the error. I assume the v20.4.0 is a global package for all users of our server, the v20.23.0 was probably installed with the --user flag.

出于某种原因,在我使用pip uninstall Virtualenv-y卸载了Virtualenv之后,服务器上仍然安装了v20.4.0,并且这个版本运行正常。我假设v20.4.0是针对我们的服务器的所有用户的全局包,v20.23.0可能是使用--user标志安装的。


▶ virtualenv --version    
/usr/local/lib/python3.9/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
virtualenv 20.4.0+ds from /usr/lib/python3/dist-packages/virtualenv/__init__.py
▶ virtualenv
/usr/local/lib/python3.9/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--read-only-app-data] [--app-data APP_DATA] [--reset-app-data] [--upgrade-embed-wheels] [--discovery {builtin}] [-p py] [--try-first-with py_exe]
[--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_sep_list] [--clear] [--no-vcs-ignore] [--system-site-packages] [--symlinks | --copies] [--no-download | --download]
[--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel] [--no-periodic-update] [--symlink-app-data] [--prompt prompt] [-h]
dest
virtualenv: error: the following arguments are required: dest
SystemExit: 2
▶ git commit -v
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/user/<user>/.cache/pre-commit/patch1684867373-780959.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...


For me on Debian after a OS upgrade, the global python3-virtualenv package had been installed, which was causing the same issue:

对于我在Debian上的操作系统升级后,已经安装了全局python3-Virtualenv包,这也导致了同样的问题:


$ pipenv install
Creating a virtualenv for this project...
Pipfile: /tmp/test/Pipfile
Using default python from /usr/bin/python3 (3.9.2) to create virtualenv...
⠹ Creating virtual environment...AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsFramework'

✘ Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]:

After a sudo apt remove python3-virtualenv and python3 -m pip install -U virtualenv pipenv error was gone for me.

在执行sudo apt删除python3-Virtualenv和python3-m pip Install-U Virtualenv pipeenv之后,我不会再犯错误了。



The same issue recently appeared on a BitBucket pipeline (while having no issue locally on a WSL pre-commit run).

同样的问题最近出现在BitBucket管道上(虽然在本地的WSL预提交运行中没有问题)。


The problem was solved by downgrading virtualenv from 20.23.0 to 20.19.0

通过将Virtualenv从20.23.0降级到20.19.0解决了该问题


更多回答

76 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com