How to setup a pipenv Python 3.6 project if OS Python version is 3.5?

Sun Bear picture Sun Bear · Apr 12, 2018 · Viewed 56k times · Source

My Ubuntu 16.04.03 is installed with Python 3.5.2. How do I setup pipenv to use Python 3.6 when my system does not have python 3.6?

$ pipenv --python 3.6
Warning: Python 3.6 was not found on your system…
You can specify specific versions of Python with:
  $ pipenv --python path/to/python

Answer

pawamoy picture pawamoy · Apr 12, 2018

Either manually write the version you need in your Pipfile:

[requires]
python_version = "3.6"

Or install it on your system. But I guess you will need the version to be installed if you plan to actually run pipenv install.

I would suggest to use pyenv: https://github.com/pyenv/pyenv.

Follow the installation instructions, then installing Python 3.6 is just a matter of

pyenv install 3.6.3

Then you can set the order of preference with

pyenv global system 3.6.3

Besides, if pyenv is available, pipenv will automatically use it to install the required version. From pipenv README:

Automatically install required Pythons, if pyenv is available.