This is a glossary of all the common issues in PyPA pip
  • 27-Dec-2022
Lightrun Team
Author Lightrun Team
Share
This is a glossary of all the common issues in PyPA pip

Troubleshooting Common Issues in PyPA pip

Lightrun Team
Lightrun Team
27-Dec-2022

Project Description

 

PyPA is the Python Packaging Authority, a group of Python developers and enthusiasts who are dedicated to improving the Python packaging ecosystem. They are responsible for maintaining and improving tools such as pip, the package manager for Python packages. pip is a command-line tool for installing and managing Python packages, which are collections of code that can be used in your Python projects. With pip, you can easily install, upgrade, and remove Python packages, as well as manage the dependencies of your projects. pip is a crucial tool for any Python developer, as it allows you to easily share and reuse code, and to easily install and manage the libraries and tools that you need for your projects.

Troubleshooting PyPA pip with the Lightrun Developer Observability Platform

 

Getting a sense of what’s actually happening inside a live application is a frustrating experience, one that relies mostly on querying and observing whatever logs were written during development.
Lightrun is a Developer Observability Platform, allowing developers to add telemetry to live applications in real-time, on-demand, and right from the IDE.
  • Instantly add logs to, set metrics in, and take snapshots of live applications
  • Insights delivered straight to your IDE or CLI
  • Works where you do: dev, QA, staging, CI/CD, and production

Start for free today

The following issues are the most popular issues regarding this project:

Raise a warning when pip falls back to the “legacy” direct install code

 

This issue arose due to virtualenvs created with virtualenv coming with wheel installed:

$ virtualenv venv
created virtual environment CPython3.8.2.final.0-64 in 222ms
  creator CPython3Posix(dest=/home/ran/venv, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/home/ran/.local/share/virtualenv/seed-app-data/v1.0.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
$ . venv/bin/activate
(venv) $ pip list
Package    Version
---------- -------
pip        20.0.2 
setuptools 46.1.3 
wheel      0.34.2 

For those using python -m venv to create virtualenvs, you may notice that wheel is not automatically included:

$ python3.8 -m venv venv
$ . venv/bin/activate
(venv) $ pip list
Package    Version
---------- -------
pip        19.2.3 
setuptools 41.2.0 

With the proliferation of virtual environments, many users may not be aware that they need to install a wheel as well. It is worth investigating if it is feasible for python -m venv to include an additional parameter allowing the installation of wheels too upon the creation of such environment.

pip editable install fails with pyproject.toml, even with no setup.py import error

 

To use setup.py and setup.cfg in ansible/ansible-builder, it is essential to have setuptools package installed beforehand as a requirement indicated within the build-system table of configurations. To rectify any issues related thereto, a patch was successfully implemented which effectively solved them all:

From dc6ad207894e62124cbeb4f4aa1cf046a4a1559d Mon Sep 17 00:00:00 2001
From: Ellen Marie Dash <me@duckie.co>
Date: Sat, 17 Oct 2020 21:07:02 -0400
Subject: [PATCH] Fix editable pip installations.

The build process needs setuptools before reading setup.py, which means
it needs to be specified in pyproject.toml's `build-system` table.
---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index e4666a4..f3c682e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -46,5 +46,5 @@ exclude = '''
 '''
 
 [build-system]
-requires = ["poetry>=1.0.5"]
+requires = ["setuptools", "poetry>=1.0.5"]
 build-backend = "poetry.masonry.api"
-- 
2.25.4

index-url extra-index-url install priority order

 

Security researchers recently revealed a new exploit, dubbed Dependency Confusion. Read the detailed post on Medium to further explore this serious vulnerability and its implications for modern development projects.

Add install option to hide “Requirement already satisfied” log info

 

A viable, effective solution is available and can easily be implemented:

pip install -r requirements.txt | grep -v 'already satisfied'

No module named pip

 

The problem is solved by uninstalling pipx, purging any associated local files in ~/.local/pipx, and finally re-issuing a fresh reinstallation with an updated version of Python.

pip install -e does not install setup.py install_requires dependencies

 

Upon further investigation, it was found that the issue could be attributed to a project_name.egg-info folder adjacent to setup.py having outdated requirements specified in its ./project_name.egg-info/requires.txt file.

By examining this bug, we can see that pip install -e operates on the project_name.egg-info folder in a setup.py directory, relying only on its outdated requires.txt file for guidance; whereas using pip install allows for the parsing of setup.py and updating ./src/project_name.egg-info/requires.txt to reflect any changes made within the code itself residing under ./src/project_name.

Additionally, an outdated project_name.egg-info folder can be easily renamed to test.egg-info without interfering with pip install -e ability to read the updated requires.txt file in its newer location and name.

The following setup.py is sufficient to reproduce the bug:

from setuptools import setup
setup(name='project', install_requires=['gitpython'])

Although the test.egg-info file is incorrectly named, its presence raises an interesting dilemma: should pip install -e double check the requires.txt with setup.py for accuracy? It remains to be determined whether this constitutes a bug or not.

More issues from PyPA repos

 

Troubleshooting pypa-pipenv | Troubleshooting pypa-setuptools

Share

It’s Really not that Complicated.

You can actually understand what’s going on inside your live applications.

Try Lightrun’s Playground

Lets Talk!

Looking for more information about Lightrun and debugging?
We’d love to hear from you!
Drop us a line and we’ll get back to you shortly.

By submitting this form, I agree to Lightrun’s Privacy Policy and Terms of Use.