pipenv requires python 3.7 but installed version is 3.8 and won't install

Question:

I know a little of Python and more than a year ago I wrote a small script, using pipenv to manage the dependencies.

The old platform was Windows 7, the current platform is Windows 10.

At that time I probably had Python 3.7 installed, now I have 3.8.3 but running:

pipenv install

Complained that:

Warning: Python 3.7 was not found on your system…
Neither 'pyenv' nor 'asdf' could be found to install Python.
You can specify specific versions of Python with:
$ pipenv --python pathtopython

This is the Pipfile

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

[packages]
python-ldap = {path = "./dependencies/python_ldap-3.1.0-cp37-cp37m-win_amd64.whl"}
requests = "~=2.0"
mysqlclient = "~=1.0"

[dev-packages]

[requires]
python_version = "3.7"

I manually edited that last line to allow 3.8, but how do I properly fix that?
I think 3.7 should be a minimum requirement — well, the script is so simple that I think even 3.0 should work.

Asked By: watery

||

Answers:

You can download Python 3.7 from the official site – https://www.python.org/downloads/

Answered By: user14023416
[requires]
python_version = "3.7"

and the error:

Warning: Python 3.7 was not found on your system…

Sort of hints that pipenv is installed but when it reads your config file, it sees that it should create environment with python 3.7, So, logically, you should install 3.7 or update the pipfile to use the python you have installed ?

Answered By: rasjani

The simple solution is, you can avoid such a problem and make it a fully system dependable python version. To make this happen, just remove python_version = "3.7" line from requires.

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

[packages]

[dev-packages]

[requires]
python_version = "3.7"

So after removing the python version, your pipfile would be like,

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

[packages]

[dev-packages]

[requires]
python_version = "*"
Answered By: Shaonsani

I have Python 3.9 installed,

and pipenv requires Python 3.6 as stated in pipfile.

So, I change the value in pipfile

[requires]
python_version = "3.6"

to

[requires]
python_version = "*"

so it can be work on any version.

I would recommend you to install pyenv (so it can manage your Python versions).

The repository of pyenv is this one:
https://github.com/pyenv/pyenv

With pyenv installed when a Pipfile requires a version of Python that you do not have on your machine it will ask if you want to install it with pyenv.
In this way you’ll be able to work in projects with different python versions without having to worry about which version the project is using.
With pyenv you can easily change between python version in your global shell as well.

Another suggestion not really realated to your question is, you should take a look on poetry to replace pipenv (it is faster because it install the dependencies in a async way), the website for poetry is this one: https://python-poetry.org/

But still, you will need something like pyenv or install another python version manually to solve your problem.

If you just wanna make the Pipfile allow you to use newer versions of python I guess you can change it like this:

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

[packages]
python-ldap = {path = "./dependencies/python_ldap-3.1.0-cp37-cp37m-win_amd64.whl"}
requests = "~=2.0"
mysqlclient = "~=1.0"

[dev-packages]

[requires]
python_version = "^3.7"

I’m not really sure if the syntax is ^3.7 or >=3.7 but should be one of this two.

Answered By: Affonso Brian

If your python command is Python 2.x, but you have a python3 command which runs Python 3.x, then you might just need to use the --python option to tell pipenv to use it:

$ pipenv install
Warning: Python >= 3.5 was not found on your system...
Neither 'pyenv' nor 'asdf' could be found to install Python.
You can specify specific versions of Python with:
$ pipenv --python path/to/python

$ pipenv --python `which python3` install
Creating a virtualenv for this project...
Answered By: qris

Install Relevant version

How to check Python Version

cmd any directory>Python -v

In My case they need Python 3.8.2
But i have Python 3.8.0 version installed
Due this i could not able over come this error

Once i install exact version i can able to run command

Answered By: Sameer Bahad

I had a similar problem and it was solved by deleting the pipfile.
The pipfile path is the path where you enter the pipenv install command in the terminal.

Answered By: Mehdi shafaghati

I meet the same problem when I move my old project to a new Laptop.

Warning: Python 3.7 was not found on your system...
Neither 'pyenv' nor 'asdf' could be found to install Python.
You can specify specific versions of Python with:
$ pipenv --python path/to/python

My way to solve the problem is simply delete the old Pipfile and input
pipenv shell in the terminal. Then it will build a new Pipfile and match your python as it should be.

Answered By: Jean

You can install pyenv simply with

curl https://pyenv.run | bash

then, when you push new changes with amplify CLI, it will ask if you wish them to install the specific Python version with Pyenv. Confirm, and problem solved in a proper way 🙂

Answered By: Tomasz Grzybowski

You can either delete the Pipfile and run pipenv install your_preferred_version again so it is installed automatically, or you can just edit the python_version in the "Pipfile".

Answered By: tenkards

Just change this part:

[requires]
python_version = "3.7"

Set the python_version to the current version of Python in your environment

Answered By: Eslam Zaid
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.