question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pipenv thinks a hidden path is a python version

See original GitHub issue
$ pipenv --python .tox/py39-lock/bin/python install .
Traceback (most recent call last):
  File "/ifs/home/dtucker/.local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1256, in invoke
    Command.invoke(self, ctx)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/cli/command.py", line 204, in cli
    clear=state.clear,
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/core.py", line 580, in ensure_project
    pypi_mirror=pypi_mirror,
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/core.py", line 498, in ensure_virtualenv
    python = ensure_python(three=three, python=python)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/core.py", line 388, in ensure_python
    path_to_python = find_a_system_python(python)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/core.py", line 354, in find_a_system_python
    python_entry = find_python(finder, line)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/utils.py", line 2196, in find_python
    result = finder.find_python_version(line)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 262, in find_python_version
    version_dict = self.parse_major(major, minor=minor, patch=patch, arch=arch)
  File "/ifs/home/dtucker/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 209, in parse_major
    int(version_dict["major"]) if version_dict.get("major") is not None else major
ValueError: invalid literal for int() with base 10: '.tox/py39-lock/bin/python'
  • Note: This was originally encountered via a tox.ini:
    commands = pipenv --python {envpython} install .
    

https://github.com/pypa/pipenv/blob/deefb637a646b4e5432e1934453da61a9683ad7e/pipenv/utils.py#L2212 Perhaps that should use parentheses instead of brackets (or just omit the . altogether)?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
hansingtcommented, Jun 14, 2022

@matteius I can reproduce the issue on Ubuntu 22.04 using the following versions:

python: 3.10.4 pipenv: 2022.6.7

Simple script to reproduce this, utilizes tox and tox-pipenv:

[tox]
requires = tox-pipenv
envlist = py310

[testenv]
skip_install = true

and the following Pipfile:

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

[packages]

[dev-packages]
pytest = "*"

[requires]
python_version = "3.10"

tox -e py310 gives the following output:

tox -e py310
.tox create: /home/tha/test/.tox/.tox
.tox installdeps: tox-pipenv, tox >= 3.25.0
py310 create: /home/tha/test/.tox/py310
ERROR: invocation failed (exit code 1), logfile: /home/tha/test/.tox/py310/log/py310-0.log
================================================================= log start ==================================================================
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/__main__.py", line 4, in <module>
    cli()
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/cli/options.py", line 56, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1637, in invoke
    super().invoke(ctx)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/vendor/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/cli/command.py", line 193, in cli
    ensure_project(
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/core.py", line 553, in ensure_project
    ensure_virtualenv(
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/core.py", line 473, in ensure_virtualenv
    python = ensure_python(project, three=three, python=python)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/core.py", line 362, in ensure_python
    path_to_python = find_a_system_python(python)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/core.py", line 333, in find_a_system_python
    python_entry = find_python(finder, line)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/utils/shell.py", line 309, in find_python
    result = finder.find_python_version(line)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 262, in find_python_version
    version_dict = self.parse_major(major, minor=minor, patch=patch, arch=arch)
  File "/home/tha/test/.tox/.tox/lib/python3.10/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 209, in parse_major
    int(version_dict["major"]) if version_dict.get("major") is not None else major
ValueError: invalid literal for int() with base 10: '.tox/bin/python'

================================================================== log end ===================================================================
ERROR: InvocationError for command /home/tha/test/.tox/.tox/bin/python -m pipenv --python .tox/bin/python (exited with code 1)
1reaction
ns-rorstencommented, Aug 8, 2022

well, the goal is to prevent it from treating a path as a python version; it’s supposed to use a python of its own if it’s a version and the specified python if it’s a path, and I think in that latter case people are taking responsibility for ensuring that executable is appropriate. So maybe in this case it would be appropriate to borrow packaging.version.VERSION_PATTERN that matches PEP 440 versions, and make sure the version is the whole string, with something like re.match(f'^{VERSION_PATTERN}$').

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is pipenv telling me the wrong version of python?
With pipenv you simply have to set the WORKON_HOME folder then pipenv install should create your virtual env under that same folder. Every...
Read more >
Pipenv install - Python - Codecademy Forums
I tried and tried but can't run piping or piping --version. I've uninstalled and installed again copied the path but it doesn't work....
Read more >
Pipenv: A Guide to the New Python Packaging Tool
Pipenv is a packaging tool for Python that solves some common problems associated with the typical workflow using pip, virtualenv, and the good...
Read more >
Django tooling with Pipenv, Pre-Commit, GitHub actions and ...
This also means that you'll end up with 2 versions of python in your computer. ... you can think of pipenv like the...
Read more >
Python versions, pyenv and pipenv - GitLab
If the pyenv directory is in your path, you can simply invoke $ pipenv --python 3.7 without you having to explicitly specify the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found