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

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

Closed
MemoonaTahira opened this issue Oct 10, 2022 · 7 comments · Fixed by #5401

Comments

@MemoonaTahira
Copy link

MemoonaTahira commented Oct 10, 2022

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?

@jerempy
Copy link
Contributor

jerempy commented Oct 10, 2022

If a full_python_version is specified when the project is installed it will be added in the [requires] section of the Pipfile in addition to the python_version. But this is just a recently added feature.
@oz123 should I take a look at refactor to have only python_version or python_full_version gets written, but not both?

@oz123
Copy link
Contributor

oz123 commented 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%.

@jerempy
Copy link
Contributor

jerempy commented Oct 10, 2022

when you have a moment @oz123 : sarugaku/plette#31

@oz123
Copy link
Contributor

oz123 commented Oct 10, 2022

Thanks for the quick response! I made a comment there.

@stewartmiles
Copy link

stewartmiles commented Oct 11, 2022

FYI: We're seeing the same issue with vanilla (i.e not conda) Python. 2022.9.24 works fine.

oz123 added a commit that referenced this issue Oct 11, 2022
matteius pushed a commit that referenced this issue Oct 12, 2022
@stewartmiles
Copy link

Hi @matteius and @oz123 while this is completed in the source it looks like we need a pipenv release to benefit from this change, any chance someone could cut and push a release?

@matteius
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants