Tobias Gårdner
Tobias Gårdner

Reputation: 163

pipenv and upgrading python version leads to error: An error occurred while installing <package>

I hope someone has some insights to this problem.

I have a Django project and we use pipenv. The project is currently running Python 3.8. I have updated all the packages in Pipfile, and it works fine. All tests pass, and when pushing the code to Bitbucket, the pipeline passes. (Docker image based on python:3.8-slim) So far so good...

Upgrading to Python 3.9

When I try to upgrade to Python 3.9, I do changes in 3 files: Pipfile, Dockerfile and bitbucket-pipelines.yml. Installing the updated environment locally and running tests works out fine. But when the code is pushed to Bitbucket, the pipeline fails. Installation of container seems to work and then it fails on pipenv install (pipenv version is 2022.11.30):

...
+ pipenv install
Creating a virtualenv for this project...
Pipfile: /opt/atlassian/pipelines/agent/build/Pipfile
Using /usr/local/bin/python3.9 (3.9.16) to create virtualenv...
created virtual environment CPython3.9.16.final.0-64 in 617ms
  creator Venv(dest=/root/.local/share/virtualenvs/build-3vGKWv3F, clear=False, no_vcs_ignore=False, global=False, describe=CPython3Posix)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
    added seed packages: pip==22.3.1, setuptools==65.6.3, wheel==0.38.4
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Successfully created virtual environment!
Virtualenv location: /root/.local/share/virtualenvs/build-3vGKWv3F
Installing dependencies from Pipfile.lock (af5a9e)...
An error occurred while installing arabic-reshaper==2.1.4 --hash=sha256:23465907417191521da568bd1ae5064eca801c52f88329ef5fdcfbac9c64888b --hash=sha256:e84b3b0ad8eae395641c94d3010b53bfed2c2b1ab80f25eb8cdc01019ddf6426 --hash=sha256:a06297fa436f56bdade4f7751710dbea5645b404debdca5017999e5233daf34a! Will try again.
An error occurred while installing asgiref==3.5.2 --hash=sha256:4a29362a6acebe09bf1d6640db38c1dc3d9217c68e6f9f6204d72667fc19a424 --hash=sha256:1d2880b792ae8757289136f1db2b7b99100ce959b2aa57fd69dab783d05afac4! Will try again.
-> This error is repeated for all packages...
...

Testing out Python 3.10

I have also tested with Python 3.10, but that does not work locally either. I get the same error as I get with Python 3.9 in the pipeline, i.e. An error occurred while installing <package>.

My environment

Macbook Pro, M1, latest updates

Upvotes: 0

Views: 936

Answers (2)

Tobias G&#229;rdner
Tobias G&#229;rdner

Reputation: 163

Problem solved, found one row in the Pipefile in the section [packages] that most likely was badly formatted: "backports.zoneinfo" = ">=0.2.1"

With that row removed, installation of 3.10 worked both locally and in the pipeline on Bitbucket!

Upvotes: 0

J_H
J_H

Reputation: 20460

Here is some advice for moving to new cPython interpreter version.

  1. Think of it as "install from scratch", rather than "preserve some pieces while upgrading".
  2. In that vein, the pinned version constraints on your deps are likely to be inappropriate for new interpreter. Consider unpinning everything, do a pip install, then pin the newly installed versions. Almost the same, change == to >=, e.g. asgiref>=3.5.2 is unpinned, then put the == back to re-pin.
  3. Consider using poetry or conda, as such upgrades are pretty painless with the help of those virt env managers. Poetry in particular offers excellent diagnostic messages on what you should specifically change to accomplish a version upgrade.

Upvotes: 1

Related Questions