module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsArmFramework
Asked Answered
E

5

20

I am trying to install python packages to a venv using poetry - on BigSur macos.

I have pyenv on stable python.

pyenv which python
/Users/josh/.pyenv/versions/3.8.6/bin/python

When I exec.

poetry shell && poetry install

I get this error but do not know what to do with it.

  AttributeError

  module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 
'CPython2macOsArmFramework'

  at ~/.pyenv/versions/3.8.2/lib/python3.8/importlib/metadata.py:79 in load
       75│         """
       76│         match = self.pattern.match(self.value)
       77│         module = import_module(match.group('module'))
       78│         attrs = filter(None, (match.group('attr') or '').split('.'))
       79│         return functools.reduce(getattr, attrs, module)
       80│ 
       81│     @property
       82│     def extras(self):
       83│         match = self.pattern.match(self.value)

Any ideas of what to troubleshoot welcome!

Eyrir answered 14/6, 2022 at 8:39 Comment(5)
Can u do poetry install -vv and check if a particular package is causing this issue.Carrelli
I get no errors when running that. Just a stacktrace on run.Eyrir
Check this out #70584480.Carrelli
That didn't help me, it pertains to Ubuntu, I am running Unix system (mac)Eyrir
Just re-installing poetry should work pip uninstall poetry && pip install poetry you can also define the version if you are not aiming for latest versionPearse
R
12

I got this error today. I'm on Ubuntu, python 3.8.10 (pyenv managed). So seeing an error with mac_os in the message felt weird. On further debugging, found that the reason behind the issue was that some other package had installed virtualenv as a dependency in my local venv. We need to get rid of it.

And the culprit package was pre-commit. Uninstalled it from local venv for now. Installing rest of the packages works without any error.

Robyn answered 25/9, 2022 at 17:10 Comment(1)
I got the same error on a ubuntu server. Issue was i had installed virtualenv with sudo. Which conflicted with the local virtualenv(installed in ~/.local) . Uninstalled the global one ( installed in. /usr/lib) using sudo pip3 uninstall virtualenv and it started working correctly.Surpassing
A
10

I was able to get around this issue by updating the version of virtualenv. At the time of this post, that was 20.24.5. I hope it works for anyone else having this issue as well

pip install virtualenv --upgrade
Archiepiscopate answered 18/10, 2023 at 18:12 Comment(1)
For me, I had to replace "pip" with "pip3". Then, it asked to run this command instead: /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -m pip install --upgrade pip.Meldon
B
7

It was late when I hit the problem, and I gave up afterward, only coming back to it a few days later.

What I think happened, in my case, is that I believe I attempted to upgrade virtualenv from a non-administrator terminal. The problem is that what should have failed had partially succeeded, leaving my system in an invalid state. I think what happened has to do with where different versions and releases of Python and Pip have been putting site-packages in various cases and various operating systems over the years.

Simply attempting to re-install virtualenv did not work. I had to uninstall it twice. Then install it fresh.

Watch where it is being uninstalled from. Your own system may need even more instances removed.

C:\Windows\System32>py -3 -m pip uninstall virtualenv
Found existing installation: virtualenv 20.24.5
Uninstalling virtualenv-20.24.5:
  Would remove:
    c:\users\MY_USER\appdata\roaming\python\python39\scripts\virtualenv.exe
    c:\users\MY_USER\appdata\roaming\python\python39\site-packages\virtualenv-20.24.5.dist-info\*
    c:\users\MY_USER\appdata\roaming\python\python39\site-packages\virtualenv\*
Proceed (Y/n)? y
Successfully uninstalled virtualenv-20.24.5

C:\Windows\System32>py -3 -m pip uninstall virtualenv
Found existing installation: virtualenv 20.7.0
Uninstalling virtualenv-20.7.0:
  Would remove:
    c:\program files\python39\lib\site-packages\virtualenv-20.7.0.dist-info\*
    c:\program files\python39\lib\site-packages\virtualenv\*
    c:\program files\python39\scripts\virtualenv.exe
Proceed (Y/n)? y
Successfully uninstalled virtualenv-20.7.0
Beveridge answered 14/9, 2023 at 16:19 Comment(3)
uninstalling twice worked for me. ThanksWheelbarrow
In my case I had to do it 4 times :DMisdo
i had to pip uninstall virtualenv then sudo pip uninstall virtualenvFloruit
C
0

I faced this issue after upgrading python from 3.9.5 to 3.9.12

I resolved it by switching from the online installer, which is deprecated, to installing through pip

Before:

export POETRY_VERSION=1.1.4
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python

After:

export POETRY_VERSION=1.1.4
pip install "poetry==$POETRY_VERSION"
Claribel answered 5/8, 2022 at 8:42 Comment(1)
I believe I similar switched a mico-release version of Python 3.9 in the past year and recently tried to upgrade virtualenv.Beveridge
L
0

In my case poetry was also missing the python executable (poetry env info). Reinstalling virtualenv, adding a new python version, and linking pyenv and poetry worked fine. My steps:

$ pyenv install 3.8.6    
$ pyenv global 3.8.6
$ python -m pip uninstall virtualenv
$ python -m pip install --use-feature=2020-resolver virtualenv

$ poetry env use 3.8.6
Creating virtualenv hpe-authn-hVOAUjOY-py3.8 in /usr/local/lib/ccs-dev/poetry/venvs
Using virtualenv: /usr/local/lib/ccs-dev/poetry/venvs/dfgrr-hVOAUjOY-py3.8

$ poetry install 
...
Lorenlorena answered 11/10, 2023 at 10:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.