11

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!

5
  • Can u do poetry install -vv and check if a particular package is causing this issue.
    – Origin
    Jun 16, 2022 at 4:42
  • I get no errors when running that. Just a stacktrace on run.
    – godhar
    Jun 16, 2022 at 7:24
  • Check this out stackoverflow.com/questions/70583980/….
    – Origin
    Jun 16, 2022 at 8:01
  • That didn't help me, it pertains to Ubuntu, I am running Unix system (mac)
    – godhar
    Jun 20, 2022 at 10:09
  • 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 version
    – Abulubad
    Oct 25 at 13:37

5 Answers 5

8

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.

2

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
1
  • 1
    uninstalling twice worked for me. Thanks
    – stm
    Sep 18 at 9:02
2

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
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"
1
  • I believe I similar switched a mico-release version of Python 3.9 in the past year and recently tried to upgrade virtualenv.
    – Kevin
    Sep 14 at 16:20
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 
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.