1

I am trying to run the command

pipenv install python==3.7.9

and getting the error below. When I run

which python

it shows "/Users/Micky/opt/anaconda3/bin/python" and the version is 3.7.9.

Can anyone tell me how?

Micky-MBP:sportanalitica Micky$ pipenv install python==3.7.9
Installing python==3.7.9...
Error:  An error occurred while installing python==3.7.9!
Error text: 
ERROR: Could not find a version that satisfies the requirement python==3.7.9
ERROR: No matching distribution found for python==3.7.9

✘ Installation Failed 
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
bisamov
  • 650
  • 1
  • 8
  • 24

2 Answers2

1

Pipenv is not used to install Python versions. You install Python separately and then use Pipenv to create and manage virtual environments, using pipenv install <package> to install Python packages.

I think what you are trying to do is to create a virtual environment that uses your Python 3.7.9 version. To do that the correct way of specifying the Python version is to pass it as a --python=</path/to/python> option. For example, for pipenv shell:

~$ pipenv shell --help
Usage: pipenv shell [OPTIONS] [SHELL_ARGS]...

  Spawns a shell within the virtualenv.

Options:
  ...
  --python TEXT       Specify which version of Python virtualenv should use.

The same option is available to pipenv install. So if you have "python3 points to /Users/Micky/opt/anaconda3/bin/python":

~$ pipenv shell --python=/Users/Micky/opt/anaconda3/bin/python

Note that you have to pass the --python option only when creating the virtual environment. Once it's created, it will "remember" it in the Pipfile to use that version.

temp$ pipenv shell --python=/usr/local/opt/python@3.7/bin/python3
...
✔ Successfully created virtual environment! 
...
Creating a Pipfile for this project...
Launching subshell in virtual environment...
...

(temp) temp$ python -V
Python 3.7.9

Once your virtual environment, you use pipenv install <package> to install Python packages (not Python itself):

(temp) temp$ pipenv install somepackage
(temp) temp$ pipenv install somepackage==1.0.0

I recommend reading the Basic Usage of Pipenv docs.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
1

From what I see, I understand that you wish to use a specific version of Python in your Pipenv. It looks like the way you are passing the parameters is wrong. The parameters you are passing is more for packages and not the version of Python.

  • To learn more on how to specify the Python version, please refer here. $ pipenv install --python 3.7.9
  • To specify the full path to your Python binary, you may refer here. $ pipenv install --python /Users/Micky/opt/anaconda3/bin/python
  • Lastly, there is a trick you can use, which is to just pipenv install. Then once you have a Pipfile, modify the Python version. Then use pipenv --rm to remove the install. Next pipenv install for the second time and it should take the version specified in the Pipfile which you modified earlier.
Raymond C.
  • 572
  • 4
  • 24