pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

Cannot lock file: `pipenv install` not working - `TypeError: Expected maxsize to be an integer or None`

Open thernstig opened this issue 2 years ago • 9 comments

Issue description

pipenv install --dev is not working. It cannot create a Pipfile.lock. It seems to be since I use Python 3.7.1. If I use 3.11.4 it works. 3.8.X also seems to work.

Expected result

I expected it to work.

Actual result

pipenv install --dev
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Locking [dev-packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed!
⠹ Locking...
Error in sys.excepthook:
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1035, in _handle_fromlist
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/environments.py", line 9, in <module>
    from pipenv.utils.shell import env_to_bool, is_env_truthy, isatty
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/utils/shell.py", line 23, in <module>
    def make_posix(path: str) -> str:
  File "/home/dragon/.pyenv/versions/3.7.1/lib/python3.7/functools.py", line 474, in lru_cache
    raise TypeError('Expected maxsize to be an integer or None')
TypeError: Expected maxsize to be an integer or None
Original exception was:
Traceback (most recent call last):
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/resolver.py", line 675, in <module>
    main()
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/resolver.py", line 653, in main
    _ensure_modules()
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/resolver.py", line 28, in _ensure_modules
    spec.loader.exec_module(pipenv)
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/__init__.py", line 40, in <module>
    from pipenv.cli import cli  # noqa
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/cli/__init__.py", line 1, in <module>
    from .command import cli  # noqa
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/cli/command.py", line 4, in <module>
    from pipenv import environments
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/environments.py", line 9, in <module>
    from pipenv.utils.shell import env_to_bool, is_env_truthy, isatty
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/utils/shell.py", line 23, in <module>
    def make_posix(path: str) -> str:
  File "/home/dragon/.pyenv/versions/3.7.1/lib/python3.7/functools.py", line 474, in lru_cache
    raise TypeError('Expected maxsize to be an integer or None')
TypeError: Expected maxsize to be an integer or None

Traceback (most recent call last):
  File "/home/dragon/.local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/cli/options.py", line 58, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/cli/command.py", line 209, in install
    do_install(
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/routines/install.py", line 164, in do_install
    do_init(
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/routines/install.py", line 672, in do_init
    do_lock(
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/routines/lock.py", line 65, in do_lock
    venv_resolve_deps(
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 849, in venv_resolve_deps
    c = resolve(cmd, st, project=project)
  File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 718, in resolve
    raise RuntimeError("Failed to lock Pipfile.lock!")
RuntimeError: Failed to lock Pipfile.lock

Steps to replicate

See above.


pipenv --support

$ pipenv --support

Pipenv version: '2023.11.15'

Pipenv location: '/home/dragon/.local/lib/python3.8/site-packages/pipenv'

Python location: '/home/dragon/.pyenv/versions/3.8.18/bin/python3.8'

OS Name: 'posix'

User pip version: '23.3.1'

user Python installations found:

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.8.18',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '5.4.0-166-generic',
 'platform_system': 'Linux',
 'platform_version': '#183-Ubuntu SMP Mon Oct 2 11:28:33 UTC 2023',
 'python_full_version': '3.8.18',
 'python_version': '3.8',
 'sys_platform': 'linux'}

System environment variables:

  • PYENV_ROOT
  • PYENV_SHELL
  • PIPENV_VENV_IN_PROJECT
  • SHLVL
  • SSH_CONNECTION
  • FZF_DEFAULT_OPTS
  • LANG
  • LOGNAME
  • EDITOR
  • XDG_SESSION_CLASS
  • PATH
  • USER
  • XDG_SESSION_TYPE
  • DIRENV_WATCHES
  • PWD
  • DIRENV_DIR
  • SSH_CLIENT
  • HELM_USER
  • XDG_SESSION_ID
  • SHELL
  • DBUS_SESSION_BUS_ADDRESS
  • MOTD_SHOWN
  • DIRENV_DIFF
  • NODE_VERSIONS
  • SSH_AGENT_PID
  • XDG_RUNTIME_DIR
  • NODE_VERSION_PREFIX
  • XDG_DATA_DIRS
  • SSH_ENV
  • TERM
  • HOME
  • SSH_TTY
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

  • PIPENV_VENV_IN_PROJECT: true

Debug–specific environment variables:

  • PATH: /home/dragon/.pyenv/versions/3.11.4/bin:/home/dragon/.pyenv/versions/3.7.1/bin:/home/dragon/.pyenv/versions/3.8.18/bin:/home/dragon/.pyenv/shims:/home/dragon/.pyenv/bin:/home/dragon/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
  • SHELL: /usr/bin/fish
  • EDITOR: code
  • LANG: en_US.UTF-8
  • PWD: /home/dragon/code/foo

Contents of Pipfile ('/home/dragon/code/foo/Pipfile'):

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

[requires]
python_version = "3.11.4"

[dev-packages]
ruff = "==0.1.5"

thernstig avatar Nov 16 '23 16:11 thernstig

I got a very similar issue but in another way, since it here was able to create the virtual environment at least. But the final error TypeError: Expected maxsize to be an integer or None was the same.

[requires]
python_version = "3.7.1"

I get:

pipenv install --dev
Creating a virtualenv for this project...
Pipfile: /home/dragon/code/foo/Pipfile
Using /home/dragon/.pyenv/versions/3.7.1/bin/python3.7m (3.7.1) to create virtualenv...
⠼ Creating virtual environment...created virtual environment CPython3.7.1.final.0-64 in 215ms
  creator CPython3Posix(dest=/home/dragon/code/foo/.venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/dragon/.local/share/virtualenv)
    added seed packages: pip==23.3.1, setuptools==68.0.0, wheel==0.41.3
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment!
Virtualenv location: /home/dragon/code/foo/.venv
Installing dependencies from Pipfile.lock (bae39e)...
Installing dependencies from Pipfile.lock (bae39e)...
[pipenv.exceptions.InstallError]: Error in sys.excepthook:
[pipenv.exceptions.InstallError]: Traceback (most recent call last):
[pipenv.exceptions.InstallError]:   File "<frozen importlib._bootstrap>", line 1035, in _handle_fromlist
[pipenv.exceptions.InstallError]:   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[pipenv.exceptions.InstallError]:   File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/environments.py", line 9, in <module>
[pipenv.exceptions.InstallError]:     from pipenv.utils.shell import env_to_bool, is_env_truthy, isatty
[pipenv.exceptions.InstallError]:   File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/utils/shell.py", line 23, in <module>
[pipenv.exceptions.InstallError]:     def make_posix(path: str) -> str:
[pipenv.exceptions.InstallError]:   File "/home/dragon/.pyenv/versions/3.7.1/lib/python3.7/functools.py", line 474, in lru_cache
[pipenv.exceptions.InstallError]:     raise TypeError('Expected maxsize to be an integer or None')
[pipenv.exceptions.InstallError]: TypeError: Expected maxsize to be an integer or None
[pipenv.exceptions.InstallError]:
[pipenv.exceptions.InstallError]: Original exception was:
[pipenv.exceptions.InstallError]: Traceback (most recent call last):
[pipenv.exceptions.InstallError]:   File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/patched/pip/__pip-runner__.py", line 50, in <module>
[pipenv.exceptions.InstallError]:     runpy.run_module("pip", run_name="__main__", alter_sys=True)
[pipenv.exceptions.InstallError]:   File "/home/dragon/.pyenv/versions/3.7.1/lib/python3.7/runpy.py", line 205, in run_module
[pipenv.exceptions.InstallError]:     return _run_module_code(code, init_globals, run_name, mod_spec)
[pipenv.exceptions.InstallError]:   File "/home/dragon/.pyenv/versions/3.7.1/lib/python3.7/runpy.py", line 96, in _run_module_code
[pipenv.exceptions.InstallError]:     mod_name, mod_spec, pkg_name, script_name)
[pipenv.exceptions.InstallError]:   File "/home/dragon/.pyenv/versions/3.7.1/lib/python3.7/runpy.py", line 85, in _run_code
[pipenv.exceptions.InstallError]:     exec(code, run_globals)
[pipenv.exceptions.InstallError]:   File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/patched/pip/__main__.py", line 28, in <module>
[pipenv.exceptions.InstallError]:     spec.loader.exec_module(pipenv)
[pipenv.exceptions.InstallError]:   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
[pipenv.exceptions.InstallError]:   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[pipenv.exceptions.InstallError]:   File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/__init__.py", line 40, in <module>
[pipenv.exceptions.InstallError]:     from pipenv.cli import cli  # noqa
[pipenv.exceptions.InstallError]:   File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/cli/__init__.py", line 1, in <module>
[pipenv.exceptions.InstallError]:     from .command import cli  # noqa
[pipenv.exceptions.InstallError]:   File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/cli/command.py", line 4, in <module>
[pipenv.exceptions.InstallError]:     from pipenv import environments
[pipenv.exceptions.InstallError]:   File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/environments.py", line 9, in <module>
[pipenv.exceptions.InstallError]:     from pipenv.utils.shell import env_to_bool, is_env_truthy, isatty
[pipenv.exceptions.InstallError]:   File "/home/dragon/.local/lib/python3.8/site-packages/pipenv/utils/shell.py", line 23, in <module>
[pipenv.exceptions.InstallError]:     def make_posix(path: str) -> str:
[pipenv.exceptions.InstallError]:   File "/home/dragon/.pyenv/versions/3.7.1/lib/python3.7/functools.py", line 474, in lru_cache
[pipenv.exceptions.InstallError]:     raise TypeError('Expected maxsize to be an integer or None')
[pipenv.exceptions.InstallError]: TypeError: Expected maxsize to be an integer or None
ERROR: Couldn't install package: {}
 Package installation failed...

thernstig avatar Nov 16 '23 16:11 thernstig

I think I know why this happens. I am unsure if it should or not, but at least I know why.

I am using pyenv. I have however installed pipenv in my user location at ~/.local/bin/pipenv. The reason for this is I want to install pyenv in one location, but still be able to use it which ever version I install with pyenv. This has always worked.

But now when I have a project using Python 3.7, it uses /home/dragon/.local/lib/python3.8/ as seen above. This fails. If I install pipenv into my pyenv version 3.7, it works to install with pipenv.

The question is then, should the scenario of having pipenv installed for 3.8 not work when later trying to do pipenv install --dev when the pipefile has 3.7?

If Python 3.7 is not supported anymore, which some recent commits seems to indicate since 3.7 is EOL, then the main README.md should be updated to remove mentions of 3.7 in its examples, right?

thernstig avatar Nov 16 '23 16:11 thernstig

python 3.7 support was dropped, pypi doesn't show support for 3.7 for 2023.11.15 -- Doc examples should be updated (if they aren't already) but could also be related to issue to https://github.com/pypa/pipenv/issues/6018 image

matteius avatar Nov 16 '23 19:11 matteius

@matteius Got it, then this can be closed. Though I did solve the problem as explained here https://github.com/pypa/pipenv/issues/6020#issuecomment-1814848040 by installing pipenv in the pyenv for Python 3.7.

The docs are not updated, check this from the top of the README.md file. image

There are another location in README.md being wrong. I also saw that there are mentions of older 3.6 (or maybe it was 3.5) versions in docs.

It should be an easy search & replace for this for anyone willing.

thernstig avatar Nov 17 '23 09:11 thernstig

I think this is related to the docs being outdated: https://github.com/pypa/pipenv/issues/6018

matteius avatar Dec 01 '23 11:12 matteius

@matteius you be the judge, I am unsure :D If it is, you can close this.

thernstig avatar Dec 01 '23 14:12 thernstig

I'll close both if we ever get to the bottom of why the updated docs aren't getting published. :-)

matteius avatar Dec 01 '23 18:12 matteius

As a temporary patch to this issue (while you upgrade your project) you can use the last major release of pipenv: pip3 install pipenv==2023.9.8.

This resolves the issue for python 3.7.

You need to do this on your main OS distribution of python (mine was Python 3.11.6 at the time of this post)

domhauton-miro avatar Dec 27 '23 19:12 domhauton-miro

To me it worked to me to update python version to 3.8 in Pipfile and Pipfile.lock manually and then run following commands:

pipenv --rm
pipenv --python 3.8

and then pipenv sync --dev worked again.

Thanks everyone for help!

navrkald avatar Jan 25 '24 17:01 navrkald