pypa / pipenv

Python Development Workflow for Humans.
https://pipenv.pypa.io
MIT License
24.82k stars 1.86k forks source link

Failure to create virtual env error on a Mac M1 with a fresh install of python 3.11.4. #5799

Closed tsmcgrath closed 2 weeks ago

tsmcgrath commented 1 year ago

I'm getting this error on a Mac M1 with a fresh install of python 3.11.4. % pipenv install Creating a virtualenv for this project... Pipfile: /Users/tim/DocumentsLocal/Github/catchtest1/Pipfile Using /Library/Frameworks/Python.framework/Versions/3.11/bin/python3 (3.11.4) to create virtualenv... ⠙ Creating virtual environment...AttributeError: 'dict' object has no attribute 'select'

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

Was here: https://github.com/conda/conda/issues/10293

calliope-pro commented 1 year ago

same here

tsmcgrath commented 1 year ago

Today, I get a different error. I don't believe changes were made - but I have been trying to solve my environment issues and might have changed something by installing mini conda.

pipenv install
Creating a virtualenv for this project... Pipfile: /Users/tim/DocumentsLocal/Github/catch23/Pipfile Using /Library/Frameworks/Python.framework/Versions/3.11/bin/python3 (3.11.4) to create virtualenv... ⠹ Creating virtual environment...RuntimeError: failed to query /Library/Frameworks/Python.framework/Versions/3.11/bin/python3 with code 1 err: 'Traceback (most recent call last):\n File "/Users/tim/Library/Python/3.9/lib/python/site-packages/virtualenv/discovery/py_info.py", line 9, in \n import json\n File "/Applications/Qgis3.30.3.app/Contents/Resources/python/json/init.py", line 106, in \n from .decoder import JSONDecoder, JSONDecodeError\n File "/Applications/Qgis3.30.3.app/Contents/Resources/python/json/decoder.py", line 3, in \n import re\n File "/Applications/Qgis3.30.3.app/Contents/Resources/python/re.py", line 125, in \n import sre_compile\n File "/Applications/Qgis3.30.3.app/Contents/Resources/python/sre_compile.py", line 17, in \n assert _sre.MAGIC == MAGIC, "SRE module mismatch"\n ^^^^^^^^^^^^^^^^^^^\nAssertionError: SRE module mismatch\n'

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

tsmcgrath commented 1 year ago

Still getting this error: tim@Timothys-MacBook-Pro catch23 % pipenv install Creating a virtualenv for this project... Pipfile: /Users/tim/DocumentsLocal/Github/catch23/Pipfile Using /Library/Frameworks/Python.framework/Versions/3.11/bin/python3 (3.11.4) to create virtualenv... ⠸ Creating virtual environment...RuntimeError: failed to query /Library/Frameworks/Python.framework/Versions/3.11/bin/python3 with code 1 err: 'Traceback (most recent call last):\n File "/Users/tim/Library/Python/3.9/lib/python/site-packages/virtualenv/discovery/py_info.py", line 9, in \n import json\n File "/Applications/Qgis3.30.3.app/Contents/Resources/python/json/init.py", line 106, in \n from .decoder import JSONDecoder, JSONDecodeError\n File "/Applications/Qgis3.30.3.app/Contents/Resources/python/json/decoder.py", line 3, in \n import re\n File "/Applications/Qgis3.30.3.app/Contents/Resources/python/re.py", line 125, in \n import sre_compile\n File "/Applications/Qgis3.30.3.app/Contents/Resources/python/sre_compile.py", line 17, in \n assert _sre.MAGIC == MAGIC, "SRE module mismatch"\n ^^^^^^^^^^^^^^^^^^^\nAssertionError: SRE module mismatch\n'

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

matteius commented 1 year ago

Have you tried uninstalling and re-isntalling virtualenv? Is this still an issue?

deronnax commented 1 year ago

We have a fleet of M1 mac in my company and we do not have this error. The path of the python3 binary (/Library/Frameworks/Python.framework/Versions/3.11/bin/python3) makes me think that OP used a system, macos-provided python, and they often come with truckload of problems since they have been (often heavily) modified.

tsmcgrath commented 1 year ago

It is still an issue. See attached. @deronnax I'm not disagreeing that it's an issue with my environment. How do I fix it? pipenv_installtest1.txt @matteius It's still a problem. After uninstall and reinstall (both venv and pipenv successful): pipenv_installtest2.txt

matteius commented 1 year ago

@tsmcgrath Possibly the PYTHONHOME and PYTHONPATH environment variables are pointing to different python versions? "Make sure you do not have any mismatch between Python interpreter version used (like 3.7) and the 're' python module (like 3.6.1)."

This is coming from: https://stackoverflow.com/questions/53600426/whats-does-assert-sre-magic-magic-sre-module-mismatch-assertionerror-sre-m

deronnax commented 1 year ago

@tsmcgrath use pyenv to get you a working, correct, vanilla python. This has become the industry standard https://github.com/pyenv/pyenv

EDIT: Ah, it looks like you are using a custom python distribution (something like conda), so you probably won't want to add another python distribution like pyenv. The error you are having is probably because you are mixing two python of different origin (e.g, the python of your system is probably called on the re stdlib module of your conda python, or vice-versa). Uninstalling and reinstalling your Conda python should fix this, unless there has been real crap made.

tsmcgrath commented 1 year ago

Thanks for the assist @matteius and @deronnax. I'll try those suggestions in a day or so as I'm about to travel.

matteius commented 1 year ago

Sounds good @tsmcgrath fwiw, I tried on my Mac M1 yesterday and it was still working. I do have pyenv, but I want to say by default it may resolve a system python, but I'd have to check again to be sure.

miqm commented 3 weeks ago

Has this been solved? I have same problem on MacOS M1 and I can't figure out why - I've removed all python versions from brew, used pyenv, but still same problems:

❯ python -m virtualenv venv

RuntimeError: No implementation for PythonInfo(spec=CPython3.11.9.final.0-64, exe=/Users/xxxx/.pyenv/versions/3.11.9/bin/python, platform=darwin, version='3.11.9 (main, Aug 20 2024, 09:28:21) [Clang 15.0.0 (clang-1500.3.9.4)]', encoding_fs_io=utf-8-utf-8)

Help, please...

miqm commented 3 weeks ago

Update - my problem is solved - it turned out I had a environment variable VIRTUALENV_SEEDER set to azdo-pip - seems like some leftover from setting up Azure Artifacts that I didn't clean up properly... 🙈

tsmcgrath commented 3 weeks ago

Sorry, I forgot about this ticket. My issues were resolved by cleaning up the environment and removing older versions of Python. I'll leave the issue open since @miqm looks to need some help. But from my point of view it can be closed. Thanks for the assist.

miqm commented 3 weeks ago

From my side it can also be closed, problem solved by removing some junk env...