Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSYS2: location not created nor specified #5446

Open
Sonnayya opened this issue Oct 29, 2022 · 20 comments
Open

MSYS2: location not created nor specified #5446

Sonnayya opened this issue Oct 29, 2022 · 20 comments
Labels
Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged. OS: Windows This issue affects the Windows Operating System. Type: Question ❔ This is a question or a request for support.

Comments

@Sonnayya
Copy link

$ pipenv --support

Pipenv version: '2022.10.25'

Pipenv location: 'C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv'

Python location: 'C:/msys64/mingw64/bin/python.exe'

OS Name: 'nt'

User pip version: '22.3'

user Python installations found:

  • 3.10.8: C:/msys64/mingw64/bin/python.exe
  • 3.10.8: C:/msys64/mingw64/bin/python3.exe
  • 3.10.8: C:/msys64/mingw64/bin/python.exe
  • 3.10.8: C:/msys64/mingw64/bin/python3.exe

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.10.8',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.19044',
 'python_full_version': '3.10.8',
 'python_version': '3.10',
 'sys_platform': 'win32'}

System environment variables:

  • ACLOCAL_PATH
  • ALLUSERSPROFILE
  • APPDATA
  • COMMONPROGRAMFILES
  • COMPUTERNAME
  • COMSPEC
  • CONFIG_SITE
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • DRIVERDATA
  • HOME
  • HOMEDRIVE
  • HOMEPATH
  • HOSTNAME
  • INFOPATH
  • LC_CTYPE
  • LOCALAPPDATA
  • LOGONSERVER
  • MANPATH
  • MINGW_CHOST
  • MINGW_PACKAGE_PREFIX
  • MINGW_PREFIX
  • MSYSCON
  • MSYSTEM
  • MSYSTEM_CARCH
  • MSYSTEM_CHOST
  • MSYSTEM_PREFIX
  • NUMBER_OF_PROCESSORS
  • OLDPWD
  • ORIGINAL_PATH
  • ORIGINAL_TEMP
  • ORIGINAL_TMP
  • OS
  • ONEDRIVE
  • PATH
  • PATHEXT
  • PKG_CONFIG_PATH
  • PRINTER
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMFILES
  • PS1
  • PSMODULEPATH
  • PUBLIC
  • PWD
  • PROGRAMDATA
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PYCHARM COMMUNITY EDITION
  • SESSIONNAME
  • SHELL
  • SHLVL
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TERM
  • TERM_PROGRAM
  • TERM_PROGRAM_VERSION
  • TMP
  • USER
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE
  • VBOX_MSI_INSTALL_PATH
  • WINDIR
  • WIX
  • XDG_DATA_DIRS
  • ZES_ENABLE_SYSMAN
  • _
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PIP_PYTHON_PATH
  • PYTHONDONTWRITEBYTECODE
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: C:\msys64\mingw64\bin;C:\msys64\usr\local\bin;C:\msys64\usr\bin;C:\msys64\usr\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\S ystem32\WindowsPowerShell\v1.0\;C:\msys64\usr\bin\site_perl;C:\msys64\usr\bin\vendor_perl;C:\msys64\usr\bin\core_perl;C:\Users\andrey\.local\bin;C:\msys64\mingw64\ bin\
  • SHELL: C:\msys64\usr\bin\bash.exe
  • PWD: C:/msys64/home/andrey/p1

Contents of Pipfile ('C:/msys64/home/andrey/p1/Pipfile'):

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.10"

Contents of Pipfile.lock ('C:/msys64/home/andrey/p1/Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "fedbd2ab7afd84cf16f128af0619749267b62277b4cb6989ef16d4bef6e4eef2"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.10"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {},
    "develop": {}
}

I am trying to create virtual environment and I got error:
$ pipenv --python 3
Creating a virtualenv for this project...
Pipfile: C:/msys64/home/andrey/p1/Pipfile
Using C:/msys64/mingw64/bin/python3.exe (3.10.8) to create virtualenv...
[ ] Creating virtual environment...created virtual environment CPython3.10.8.final.0-64 in 531ms
creator Venv(dest=C:/Users/andrey/.virtualenvs/p1-E5LPA_VZ, clear=False, no_vcs_ignore=False, global=False, describe=CPython3Windows)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:/Users/andrey/AppData/Local/pypa/virtualenv)
added seed packages: pip==22.3, setuptools==65.5.0, wheel==0.37.1
activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

Successfully created virtual environment!
Virtualenv location: C:/Users/andrey/.virtualenvs/p1-E5LPA_VZ
Traceback (most recent call last):
File "C:/msys64/mingw64/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:/msys64/mingw64/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:/Users/andrey/.local/bin/pipenv.exe/main.py", line 7, in
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/cli/options.py", line 57, in main
return super().main(*args, **kwargs, windows_expand_args=False)
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 1637, in invoke
super().invoke(ctx)
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/cli/command.py", line 207, in cli
ensure_project(
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/core.py", line 539, in ensure_project
path_to_python = project._which("python") or project._which("py")
File "C:/Users/andrey/.local/lib/python3.10-mingw_x86_64/site-packages/pipenv/project.py", line 1124, in _which
raise RuntimeError("location not created nor specified")
RuntimeError: location not created nor specified

@matteius
Copy link
Member

You need to add your Python location to the PATH.

@matteius matteius added the Type: Question ❔ This is a question or a request for support. label Oct 30, 2022
@Sonnayya
Copy link
Author

Hello, @matteius!

What Python location should I add to the PATH?
What PATH should I use? Windows or Mingw64?

$ echo $PATH
/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/C/Users/andrey/.local/bin
$ where python
C:\msys64\mingw64\bin\python.exe

Best regards,
S.

Sonnayya pushed a commit to Sonnayya/pipenv that referenced this issue Nov 1, 2022
@matteius
Copy link
Member

matteius commented Nov 5, 2022

Hmm, I am not sure @Sonnayya -- have you tried using git shell for windows? It is a well maintained Mingw64 shell, I use it and havent't had problems. Check: https://gitforwindows.org/

@matteius matteius added the OS: Windows This issue affects the Windows Operating System. label Nov 5, 2022
@matteius
Copy link
Member

matteius commented Dec 3, 2022

@Sonnayya Were you able to get this sorted out?

@turutcrane
Copy link

I afraid that if pip is installed by pacman (ex. mingw-w64-x86_64-python-pip), virtualenv activatation script's
path is virtualenv_location/bin/activate not virtualenv_location/Scripts/activate.bat.

So, project.virtualenv_exists is False. Then project._which("python") fails.

@turutcrane
Copy link

In windows msys2, references to Scripts directory should also check the bin directory.
And references to Scripts/python.exe should also check bin/python.exe .

@matteius
Copy link
Member

Please try with latest pipenv==2023.5.19 where I totally refactored pythonfinder to a new major version and believe addressed many of these types of issues.

@matteius matteius added the Status: Awaiting Update ⏳ This issue requires more information before assistance can be provided. label May 19, 2023
@turutcrane
Copy link

I tried pienv===2023.5.19, but encountered another issue.

pipenv shell produced "RecursionError: maximum recursion depth exceeded".

environment vairables

PYTHONUSERBASE=/home/turu/py-usersite
PIPENV_VENV_IN_PROJECT=1
WORKON_HOME=/home/turu/py-venvs

Used command

$ mkdir pipenv-test
$ cd pipenv-test
$ pacman -S mingw64/mingw-w64-x86_64-python-pip
$ pip install --user pipenv==2023.5.19
$ pipenv install
$ pipenv shell

Output logs

15:28$ pip install --user pipenv==2023.5.19
Collecting pipenv==2023.5.19
  Using cached pipenv-2023.5.19-py3-none-any.whl (2.9 MB)
Requirement already satisfied: certifi in d:/diskd/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages (from pipenv==2023.5.19) (2023.5.7)
Requirement already satisfied: setuptools>=67.0.0 in d:/diskd/develop/msys64/mingw64/lib/python3.10/site-packages (from pipenv==2023.5.19) (67.7.2)
Requirement already satisfied: virtualenv-clone>=0.2.5 in d:/diskd/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages (from pipenv==2023.5.19) (0.5.7)
Requirement already satisfied: virtualenv>=20.17.1 in d:/diskd/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages (from pipenv==2023.5.19) (20.23.0)
Requirement already satisfied: distlib<1,>=0.3.6 in d:/diskd/develop/msys64/mingw64/lib/python3.10/site-packages (from virtualenv>=20.17.1->pipenv==2023.5.19) (0.3.6)
Requirement already satisfied: filelock<4,>=3.11 in d:/diskd/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages (from virtualenv>=20.17.1->pipenv==2023.5.19) (3.12.0)
Requirement already satisfied: platformdirs<4,>=3.2 in d:/diskd/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages (from virtualenv>=20.17.1->pipenv==2023.5.19) (3.5.1)
Installing collected packages: pipenv
Successfully installed pipenv-2023.5.19
16:06$ pipenv install
Creating a virtualenv for this project...
Pipfile: D:/DiskD/develop/pipenv-test/Pipfile
Using default python from D:/DiskD/develop/msys64/mingw64/bin/python.exe (3.10.11) to create virtualenv...
[ ===] Creating virtual environment...created virtual environment CPython3.10.11.final.0-64 in 337ms
  creator CPython3Windows(dest=D:/DiskD/develop/pipenv-test/.venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:/Users/turu/AppData/Local/pypa/virtualenv)
    added seed packages: pip==23.1.2, setuptools==67.7.2, wheel==0.40.0
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

Successfully created virtual environment!
Virtualenv location: D:/DiskD/develop/pipenv-test/.venv
Creating a Pipfile for this project...
Creating a virtualenv for this project...
Pipfile: D:/DiskD/develop/pipenv-test/Pipfile
Using default python from D:/DiskD/develop/msys64/mingw64/bin/python.exe (3.10.11) to create virtualenv...
[ ===] Creating virtual environment...created virtual environment CPython3.10.11.final.0-64 in 387ms
  creator CPython3Windows(dest=D:/DiskD/develop/pipenv-test/.venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:/Users/turu/AppData/Local/pypa/virtualenv)
    added seed packages: pip==23.1.2, setuptools==67.7.2, wheel==0.40.0
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

Successfully created virtual environment!

Virtualenv location: D:/DiskD/develop/pipenv-test/.venv
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Locking [dev-packages] dependencies...
Updated Pipfile.lock (fedbd2ab7afd84cf16f128af0619749267b62277b4cb6989ef16d4bef6e4eef2)!
Installing dependencies from Pipfile.lock (e4eef2)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
16:19$ pipenv shell
Traceback (most recent call last):
  File "D:/DiskD/develop/msys64/mingw64/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:/DiskD/develop/msys64/mingw64/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/bin/pipenv.exe/__main__.py", line 7, in <module>
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/cli/options.py", line 58, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/cli/command.py", line 429, in shell
    do_shell(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/routines/shell.py", line 14, in do_shell
    ensure_project(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/utils/project.py", line 32, in ensure_project
    ensure_virtualenv(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/utils/virtualenv.py", line 148, in ensure_virtualenv
    python = ensure_python(project, python=python)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/utils/virtualenv.py", line 242, in ensure_python
    path_to_python = find_a_system_python(python)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/utils/virtualenv.py", line 359, in find_a_system_python
    python_entry = find_python(finder, line)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/utils/shell.py", line 259, in find_python
    result = finder.find_python_version(line)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 174, in find_python_version
    return self.system_path.find_python_version(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 471, in find_python_version
    ver = next(iter(self.get_pythons(sub_finder)), None)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 405, in get_pythons
    pythons = [entry for entry in self._get_all_pythons(finder)]
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 405, in <listcomp>
    pythons = [entry for entry in self._get_all_pythons(finder)]
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 397, in _get_all_pythons
    for python in self._filter_paths(finder):
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 390, in _filter_paths
    python_versions = finder(path)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 449, in sub_finder
    return obj.find_python_version(major, minor, patch, pre, dev, arch, name)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pythonfinder/models/mixins.py", line 304, in find_python_version
    results = sorted(matching_pythons, key=lambda r: (r[1], r[0]), reverse=True)
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 909, in __eq__
    return self.dict() == other.dict()
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 449, in dict
    return dict(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 868, in _iter
    v = self._get_value(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 761, in _get_value
    return {
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 762, in <dictcomp>
    k_: cls._get_value(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 743, in _get_value
    v_dict = v.dict(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 449, in dict
    return dict(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 868, in _iter

   loop ,,,,

   File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 449, in dict
    return dict(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 868, in _iter
    v = self._get_value(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 761, in _get_value
    return {
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 762, in <dictcomp>
    k_: cls._get_value(
  File "D:/DiskD/develop/msys64/home/turu/py-usersite/lib/python3.10-mingw_x86_64/site-packages/pipenv/vendor/pydantic/main.py", line 741, in _get_value
    if isinstance(v, BaseModel):
RecursionError: maximum recursion depth exceeded

@turutcrane
Copy link

turutcrane commented May 20, 2023

I suspect that this original bug may be related to virtualenv rather than pipenv. Specifically, when running it with msys2, it creates the virtual_env/bin directory instead of virtual_env/Scripts.

@turutcrane
Copy link

Do I need to add another issue for "RecursionError: maximum recursion depth exceeded" problem?

@matteius matteius reopened this May 20, 2023
@matteius
Copy link
Member

@turutcrane Yeah it would be good to open an issue if you are getting that stack trace -- I haven't seen the maximum recursion depth exceeded problem on windows (git shell or power shell), ubuntu or mac os -- please provide as much detail as possible in the issue report.

@matteius
Copy link
Member

matteius commented Jun 1, 2023

I suspect that this original bug may be related to virtualenv rather than pipenv. Specifically, when running it with msys2, it creates the virtual_env/bin directory instead of virtual_env/Scripts.

I have no idea how we are going to pick that one apart -- is there a way to detect the shell is definitely MSYS2?

@matteius
Copy link
Member

matteius commented Jun 1, 2023

FWIW, I use Git Bash which under the hood uses MSYS2 according to the Task Manager, and I don't have this issue.

@turutcrane
Copy link

turutcrane commented Jun 8, 2023

I have found that 3 type pythons exist in in windows.

  1. Installed by official installer from python.org. (I'm assuming it's the same for what's installed from the Microsoft store).
  2. Installed by MSYS environment of MSYS2 (installed by 'packan -S msys/python' command)
  3. Installed by MINGW64 environment of MSYS2 (installed by 'pacman -S mingw64/mingw-w64-x86_64-python' command)

(I think that the one installed in the environment other than MSYS of MSYS2 is the same as 3. See. https://www.msys2.org/docs/environments/ )

My environment is 3rd.
And I afraid that pipenv has trouble in only 3rd.

I execute this script in 3 environments.

import sysconfig
import sys
import os

print("Version:", sys.version)
print("Scheme:", sysconfig.get_default_scheme())
print("os.name:", os.name)
print("builin_module_names", sys.builtin_module_names)

Output by 1 (Officila windows build)

Version: 3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)]
Scheme: nt
os.name: nt
builin_module_names ('_abc', '_ast', '_bisect', '_blake2', '_codecs', '_codecs_cn', '_codecs_hk', '_codecs_iso2022', '_codecs_jp', '_codecs_kr', '_codecs_tw', '_collections', '_contextvars', '_csv', '_datetime', '_functools', '_heapq', '_imp', '_io', '_json', '_locale', '_lsprof', '_md5', '_multibytecodec', '_opcode', '_operator', '_pickle', '_random', '_sha1', '_sha256', '_sha3', '_sha512', '_signal', '_sre', '_stat', '_statistics', '_string', '_struct', '_symtable', '_thread', '_tokenize', '_tracemalloc', '_typing', '_warnings', '_weakref', '_winapi', '_xxsubinterpreters', 'array', 'atexit', 'audioop', 'binascii', 'builtins', 'cmath', 'errno', 'faulthandler', 'gc', 'itertools', 'marshal', 'math', 'mmap', 'msvcrt', 'nt', 'sys', 'time', 'winreg', 'xxsubtype', 'zlib')

Output by 2 (MSYS environment in MSYS2)

Version: 3.11.3 (main, May 20 2023, 12:14:18) [GCC 11.3.0]
Scheme: posix_prefix
os.name: posix
builin_module_names ('_abc', '_ast', '_codecs', '_collections', '_functools', '_imp', '_io', '_locale', '_operator', '_signal', '_sre', '_stat', '_string', '_symtable', '_thread', '_tokenize', '_tracemalloc', '_warnings', '_weakref', 'atexit', 'builtins', 'errno', 'faulthandler', 'gc', 'itertools', 'marshal', 'posix', 'pwd', 'sys', 'time', 'xxsubtype')

2nd does not have nt module, So os.name == 'posix'

Output by 3 (MINGW64 environment in MSYS2)

Version: 3.10.11 (main, Apr  7 2023, 17:44:59)  [GCC 12.2.0 64 bit (AMD64)]
Scheme: posix_prefix
os.name: nt
builin_module_names ('_abc', '_ast', '_codecs', '_collections', '_functools', '_imp', '_io', '_locale', '_operator', '_signal', '_sre', '_stat', '_string', '_symtable', '_thread', '_tracemalloc', '_warnings', '_weakref', '_winapi', 'atexit', 'builtins', 'errno', 'faulthandler', 'gc', 'itertools', 'marshal', 'msvcrt', 'nt', 'sys', 'time', 'winreg', 'xxsubtype')

sysconfig.py of MINGW64 environment is patched by https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-python/0024-MINGW-generalization-of-posix-build-in-sysconfig.py.patch .
So, scheme is posix_prefix.

I tryed that some (os.name == 'nt') condition by (os.name == 'nt' and 'nt' in sysconfig.get_default_scheme()), then
'location not created nor specified' error disapeared. But it seems that activation script is not called by pipenv shell.

P.S.
I hope MSYS2 environment can be detected by MSYSTEM environment value. But we can use python.org's python in MINGW64 envrionment. I think we should depend on sysconfig information, though I do not know we can do.

@matteius
Copy link
Member

@turutcrane the MSYS2 variable might be promising -- the problem with sysconfig is with older versions of python like 3.7 -- I tried to introduce some usage of it prior but it broke on certain linux systems. Anyway I've run out of time on pipenv things this week, will check back again soon.

@QAston
Copy link

QAston commented Aug 26, 2023

i have the same issue with mingw-w64's python install. From @turutcrane 's post it seems that the check should be based on scheme+os.name, not the env var name.

@matteius
Copy link
Member

Feel free to open a PR, my time is limited and may not be able to deep dive this soon.

@matteius matteius added Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged. and removed Status: Awaiting Update ⏳ This issue requires more information before assistance can be provided. labels Aug 28, 2023
@aidenfoxx
Copy link

I'm also running into this issue, but hit a roadblock debugging it. I don't fully understand the suggestions from the previous comments, but as noted by @turutcrane we seem to be in a bit of a mixed state, with a posix scheme but nt for os.name. So our virtual env is outputted is in posix format, but "pipenv" searches as if we were nt, based on os.name:

    @property
    def virtualenv_exists(self) -> bool:
        if os.path.exists(self.virtualenv_location):
            if os.name == "nt": # Issue here
                extra = ["Scripts", "activate.bat"]
            else:
                extra = ["bin", "activate"]
            ...

I can work around this by either symlinking the "bin" folder to "Scripts", or updating the above code to check if sysconfig.get_default_scheme() == "nt".

But then I'm hitting another seemingly related issue when installing "PyGObject":

  building 'cairo._cairo' extension
  error: --plat-name must be one of ('win32', 'win-amd64', 'win-arm32', 'win-arm64')
  error: subprocess-exited-with-error

@aidenfoxx
Copy link

The above errors was solved by using the SETUPTOOLS_USE_DISTUTILS=stdlib var as suggested in this thread (pyproj4/pyproj#1009 (comment)), and seems unrelated to this issue. I've now managed to get everything working. 😄

@goyalyashpal
Copy link

is this issue resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged. OS: Windows This issue affects the Windows Operating System. Type: Question ❔ This is a question or a request for support.
Projects
None yet
Development

No branches or pull requests

6 participants