"Failed to create interpreter": No attribute "CPython2macOsFramework"
Hi!
I tried to create a new project (in a new window), and with it's own venv, based on the Python 3.8 that PyCharm found on my Ubuntu Linux, but I got the error “Failed to create interpreter”:
Executed command:
/usr/bin/python3.8 /snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz /mnt/4AF15A0435E762B4/mypython/Magnetic-Declination/.venv
Error occurred:
AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsFramework'
Command output:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/__main__.py", line 163, in <module>
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/__main__.py", line 159, in run
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/virtualenv/__main__.py", line 18, in run
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/virtualenv/run/__init__.py", line 31, in cli_run
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/virtualenv/run/__init__.py", line 49, in session_via_cli
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/virtualenv/run/__init__.py", line 82, in build_parser
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/virtualenv/run/plugin/creators.py", line 24, in __init__
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/virtualenv/run/plugin/creators.py", line 31, in for_interpreter
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/virtualenv/run/plugin/base.py", line 45, in options
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/virtualenv/run/plugin/base.py", line 24, in entry_points_for
File "/snap/pycharm-community/388/plugins/python-ce/helpers/virtualenv-20.24.5.pyz/virtualenv/run/plugin/base.py", line 24, in <genexpr>
File "/usr/lib/python3.8/importlib/metadata.py", line 79, in load
return functools.reduce(getattr, attrs, module)
AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsFramework'
How can I solve that?
Please sign in to leave a comment.
It seems I have found a solution:
In Terminal (on Ubuntu) I did:
:~$ pip install virtualenv --upgrade
Then in Pycharm I choose: File → Settings → Project: xxx → Python Interpreter
That window showed “No interpreter”. I pressed Add Interpreter. Now it succeeded.
I found the inspiration here: https://stackoverflow.com/questions/72613928/module-virtualenv-create-via-global-ref-builtin-cpython-mac-os-has-no-attribut
I was having the same issue, and Henrik's solution solved the problem for me as well.
It took some fooling around to figure out which Python environment to upgrade. I figured out that I had to update the version of Ptython that the new env would be based on, as show in the "Base python":" field of the “Add Python Interpreter” dialog. For me, this value was “/usr/local/bin/python3.9” and so the fix for me was to run "/usr/local/bin/pip3.9 install virtualenv --upgrade",