[Python] How to configure python virtual environment with different python version?

Discussão em 'Python' iniciado por Stack, Março 24, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to set virtual environment with a different python version.

    The default global version is Python 3.11.0

    I have installed virtualenv using pip install virtualenv

    Command to create virtualenv with different python version is virtualenv -p "C:/Python310/python.exe" .venv

    Error when I run the above command is

    RuntimeError: failed to query C:\Python310\python.exe with code 1 err:
    Traceback (most recent call last):
    File "C:\Python311\Lib\site-packages\virtualenv\discovery\py_info.py", line 8, in <module>
    import json
    File "C:\Python311\lib\json\__init__.py", line 106, in <module>
    from .decoder import JSONDecoder, JSONDecodeError
    File "C:\Python311\lib\json\decoder.py", line 3, in <module>
    import re
    File "C:\Python311\lib\re\__init__.py", line 125, in <module>
    from . import _compiler, _parser
    File "C:\Python311\lib\re\_compiler.py", line 18, in <module>
    assert _sre.MAGIC == MAGIC, "SRE module mismatch"
    AssertionError: SRE module mismatch


    Not sure what I am missing here. Any guidance is appreciated.

    Continue reading...

Compartilhe esta Página