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.

using conda python to create pipenv adds both python_version and python_full_version to pipfile

See original GitHub issue

Hello,

If I use a miniconda environment’s python for creating a pipenv environment, it adds BOTH, a python_version and python_full_version (e.g. 3.9 and 3.9.13) to the pipfile, and that throws an error.

System details:

I am using Ubuntu 22.04 via WSL. System python is: 3.10.6 Pip version is: 22.2.2 Pipenv installed via pip (outside of any environment): 2022.10.9 Conda version is: 22.9.0 All are the latest right now

Steps to reproduce the error:

(mlzoomcamp is a conda environment with python 3.9.13 (but I also used a conda env with python 3.10 and the same issue persisted))

(base) mona@Memoona-PC:~$ pipenv --python=/home/mona/miniconda3/envs/mlzoomcamp/bin/python
# runs fine, but when I install something:
(base) mona@Memoona-PC:~/extra$ pipenv install numpy

It installs numpy correctly, but then throws this error:

Installing numpy...
Adding numpy to Pipfile's [packages]...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Traceback (most recent call last):
  File "/home/mona/.local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/cli/options.py", line 57, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/cli/command.py", line 236, in install
    do_install(
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/core.py", line 2389, in do_install
    do_init(
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/core.py", line 1303, in do_init
    do_lock(
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/core.py", line 1070, in do_lock
    lockfile = project._lockfile(categories=lockfile_categories)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/project.py", line 581, in _lockfile
    plette.Pipfile.load(pf), categories=categories
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/plette/pipfiles.py", line 59, in load
    return cls(data)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/plette/models/base.py", line 49, in __init__
    self.validate(data)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/plette/pipfiles.py", line 43, in validate
    klass.validate(data[key])
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/plette/models/base.py", line 81, in validate
    return validate(cls, data)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/plette/models/base.py", line 38, in validate
    raise ValidationError(data, v)
pipenv.vendor.plette.models.base.ValidationError: {'python_version': '3.9', 'python_full_version': '3.9.13'}
python_full_version: 'python_version' must not be present with 'python_full_version'
python_version: 'python_full_version' must not be present with 'python_version'

The pipenv file at this time looks like this:

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

[packages]
numpy = "*"

[dev-packages]

[requires]
python_version = "3.9"
python_full_version = "3.9.13"

I looked at the pipfile before the install command, and it has already added the 2 versions as soon as the environment was created.

I did find a fix, to manually remove the python_version line from pipfile.

Also, if I use the system python to create an environment, this issue doesn’t happen, so this is most likely a conda issue. Do I have to manually remove the python_version each time from the pipfile?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
matteiuscommented, Oct 12, 2022

Thanks @stewartmiles – I just pushed the buttons – new release is building now.

1reaction
oz123commented, Oct 10, 2022

@jerempy can you please submit this patch upstream in Plette? https://github.com/sarugaku/plette/blob/master/src/plette/models/sections.py#L20 image

IMHO the rule should be oneof, but I am not familiar with Cerberus. To say for 100%.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pipenv with Conda? - python - Stack Overflow
You can setup Pipenv to use Conda's Python executable and site packages directory (ref). pipenv --python=$(conda run which python) --site- ...
Read more >
Pipenv: A Guide to the New Python Packaging Tool
Pipenv is a packaging tool for Python that solves some common problems associated ... You'll notice that two files get created, a Pipfile...
Read more >
Basic Usage of Pipenv - Read the Docs
Pipenv is a reference implementation for using Pipfile. ... Ideally, you should only have one target Python version, as this is a deployment...
Read more >
Pipenv vs Conda (for Data Scientists) | by Dr Soumaya Mauthoor
Pipenv uses two files to specify dependencies: Pipfile for direct dependencies and Pipfile.lock for both direct and indirect dependencies. Creating an an ...
Read more >
How to Manage your Python Projects with Pipenv and Pyenv
Set/change a Python version locally for a project. Create and manage virtual environments. Installation. On macOS, you can install this tool ...
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