Set python version when creating virtualenv using pipenv

Set python version when creating virtualenv using pipenv

Edit the Pipfile is the right way to go if you want to change the Python version of an existing environment.

If you want to create a new environment using Python 3.6, you can run

pipenv install --python 3.6

rather than

pipenv install --three

and that should do the trick.

Just be certain to delete the old Pipfile(s) if you create the new environment or else the commands will fail.

When setting up your pipenv you can specify the version of Python by using: pipenv --python 3.6, to use Python3.6.

Editing the Pipfile also works, by changing:

python_version = 3.6.6

to the specific version of Python you want.

If you did all of this and are still having trouble with accessing the correct version of Python from within pipenv shell then you might want to check your .bashrc file to be sure that you dont have an alias for a specific version of Python.

Set python version when creating virtualenv using pipenv

If you want to create a virtual environment for your project the answers above might not work for you. For instance, if you have multiple versions of python installed and you had to rename the executables like I had to in the below example, OR for the same project you might want to create virtual environments that use different python versions.

When creating virtual environments for your projects, you can more specific and specify the path of the python executable.

Remember to run the below command relative to the project folder.

pipenv install --python C:Python373python373.exe

Leave a Reply

Your email address will not be published. Required fields are marked *