xtian
xtian

Reputation: 2947

Pipenv not working after Debian system upgrade--maybe partial uninstall?

Seems pipenv was uninstalled (not intentionally) during a system update and some config directories were left behind causing it to not run properly? If I try to run pipenv, I get:

> $ pipenv
Traceback (most recent call last):
File "/home/hostname/username/.local/bin/pipenv", line 5, in <module>
    from pipenv import cli
ModuleNotFoundError: No module named 'pipenv'

--

I have a project Django website running on a Debian box at home. After updating Debian to the latest stable release (bookworm), I'm gearing up to update Python and Django. The NGINX version of the project is running fine, but I can't get pipenv to work in the dev version. (see error above)

I found an issue ticket with the same problem. This user resolved the issue by uninstalling and reinstalling: I can't use pipenv after upgrading my Linux Mint to the latest version (Vera). #5609

Strangely, I can't find an installation of pipenv on this box post update (no clue what I could have done). First I checked Pip as its the "preferred" install method. I searched pip list, there's nothing.

> $ pip list | grep pipenv

If I try uninstalling, there's nothing:

> $ python -m pip uninstall pipenv
error: externally-managed-environment
[...]

Debian also has versions of some python packages. The proper name to search for is confirmed with apt search:

> $ sudo apt search pipenv
Sorting... Done
Full Text Search... Done
pipenv/stable 2022.12.19+ds-1 all
Python package manager based on virtualenv and Pipfiles

Checking installed packages I get that strange Traceback error, but clearly module not found:

> $ sudo apt list --installed | pipenv

Traceback (most recent call last):
File "/home/hostname/username/.local/bin/pipenv", line 5, in <module>
    from pipenv import cli
ModuleNotFoundError: No module named 'pipenv'

One more try:

> $ sudo apt --purge remove pipenv
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'pipenv' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.

Evidently there's nothing to uninstall, so I try to reinstall it with pipx:

> $ pipx install pipenv
⚠️  File exists at /home/hostname/username/.local/bin/pipenv and points to /home/hostname/username/.local/bin/pipenv,
    not /home/hostname/username/.local/pipx/venvs/pipenv/bin/pipenv. Not modifying.
⚠️  File exists at /home/hostname/username/.local/bin/pipenv-resolver and points to
    /home/hostname/username/.local/bin/pipenv-resolver, not
    /home/hostname/username/.local/pipx/venvs/pipenv/bin/pipenv-resolver. Not modifying.
installed package pipenv 2024.4.0, installed using Python 3.11.2
    - pipenv (symlink missing or pointing to unexpected location)
    - pipenv-resolver (symlink missing or pointing to unexpected location)
done! ✨ 🌟 ✨

It will install (done), but it still won't work right. I'm guessing the Traceback is showing me that pipenv is configured, but not installed?

What's the solution?

Should I start by deleting these files the pipx install script complained about in ~/.local?

/home/hostname/username/.local/bin/pipenv 
/home/hostname/username/.local/bin/pipenv-resolver

PS. This whole machine is my personal mirror of a project machine at work. That other machine has pipenv installed both with pip and with apt.

Upvotes: 0

Views: 43

Answers (0)

Related Questions