简体   繁体   中英

Why is Pipenv not using the correct version of Python when installing packages?

I have read various other similar questions without finding one that matches my issue. Feel free to redirect me if I have missed one.

I have Python 3.10.7 installed on my system (Arch Linux) and I need to work on an older project that uses Python 3.6.9.
I know this project works with 3.6.9 and its dependencies are correctly installed because I can see it running fine in a docker container that I have entered to check the version of Python.

As I have tried that several times I make sure to start again with a fresh environment with:

pipenv --rm
rm Pipfile

Then I do:

pipenv --python 3.6.9

Python 3.6.9 is installed with Pyenv successfully and so is the virtual environment.

If I do pipenv shell then python --version is Python 3.6.9 as expected. Then I Ctrl-D to get out of the environment.

I then do pipenv install -r requirements.txt and that crashes with the following traceback:

Requirements file provided! Importing into Pipfile...
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed! 

    Traceback (most recent call last):
      File "/usr/lib/python3.10/site-packages/pipenv/resolver.py", line 867, in <module>
        main()
      File "/usr/lib/python3.10/site-packages/pipenv/resolver.py", line 844, in main
        from pipenv.vendor.vistir.misc import replace_with_text_stream
      File "/usr/lib/python3.10/site-packages/pipenv/__init__.py", line 58, in <module>
        from .cli import cli
      File "/usr/lib/python3.10/site-packages/pipenv/cli/__init__.py", line 1, in <module>
        from .command import cli  # noqa
      File "/usr/lib/python3.10/site-packages/pipenv/cli/command.py", line 7, in <module>
        from pipenv.cli.options import (
      File "/usr/lib/python3.10/site-packages/pipenv/cli/options.py", line 3, in <module>
        from pipenv.project import Project
      File "/usr/lib/python3.10/site-packages/pipenv/project.py", line 2
        from __future__ import annotations
        ^
    SyntaxError: future feature annotations is not defined

Correct me if I'm wrong, I understand that the installation is using Python 3.10 here while the code is expected to be run with 3.6 where annotations is in future.

What did I do wrong?

Python 3.6 support was dropped by pipenv on 2022.4.20 . Please check the pipenv version on your docker container if you're using an older version of pipenv in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM