Gangmax Blog

Pipenv Configuration Changes After Upgrading Python

After I upgraded Python version from “3.8” to “3.10”(via pyenv), I got an error when starting a service written in Python running with “Pipenv“ which complained that the virtual environment couldn’t start. I fixed this issue by doing the following steps.

  1. Run the “pip install pipenv” command to install the “pipenv” package. Since the new Python “3.10” version doesn’t have this package yet.

  2. Remove the existing virtual environment created by the previous “pipenv” execution, and then run the “pipenv shell” again to regenerate it.

  3. Running “pipenv shell” to enter the virtual environment, then run “pip install …” to install the dependencies. Note that, for the “protobuf“ package, the version number should be set explicitly as “pip install protobuf~=3.19.4”. The reason is that the latest “4.21.x” version “protobuf” package cannot work properly with the auto-generated Python code in the project which was generated by the protoc version “3.9.2”.

  4. Run “pipenv lock” to generate the “Pipfile.lock” file.

Done.

Comments