Skip to content

ModuleNotFoundError: No module named 'packaging' #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
moreati opened this issue Nov 29, 2024 · 3 comments · Fixed by #5
Closed

ModuleNotFoundError: No module named 'packaging' #2

moreati opened this issue Nov 29, 2024 · 3 comments · Fixed by #5

Comments

@moreati
Copy link
Owner

moreati commented Nov 29, 2024

moreati.uv.pip tries to use the Python module packaging. This doesn't exist by default, in a virtualenv created by uv.

TASK [Install paramiko] *******************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'packaging'
fatal: [slinger.internal]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (packaging) on slinger.internal's Python /home/slinger/.ansible_venv/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}
@jamescooke
Copy link

Interested to hear what you think the solution is here. Maybe...

  1. Install packaging if it's not already in place.
  2. Adjust this repo to not require anything that packaging requires (maybe uv can provide 🙏🏻)
  3. Something else? 🤔

@moreati
Copy link
Owner Author

moreati commented Nov 29, 2024

2. Adjust this repo to not require anything that packaging requires (maybe uv can provide 🙏🏻)

That's the goal, no plan or time scale yet. Best guess it may involve parsing the stdout of uv.

@moreati
Copy link
Owner Author

moreati commented Nov 29, 2024

charliermarsh added a commit to astral-sh/uv that referenced this issue Dec 2, 2024
## Summary

This proposes adding the command line option `uv pip uninstall --dry-run
...`, complementing the existing `uv pip install --dry-run ...` added
for #1244 in #1436.

This option does not exist in PyPA's `pip uninstall`, if adopted it
would be unique to `uv pip`. The code should be considered PoC, it is
baby's first Rust.

The initial motivation was while investigating
moreati/ansible-uv#2 - to allow Ansible module
`moreati.uv.pip` to work with`state: absent` in "check_mode" (Ansible's
equivalent of a dry run), without requiring `packaging` or `setuptools`.

## Test Plan

One new unit test has been added. I pedge to add more if the feature is
desired/accepted

Example usage

```console
➜  uv git:(pip-uninstall--dry-run) rm -rf .venv
➜  uv git:(pip-uninstall--dry-run) ./target/debug/uv venv                   
Using CPython 3.13.0
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
➜  uv git:(pip-uninstall--dry-run) ./target/debug/uv pip install httpx      
Resolved 7 packages in 178ms
Prepared 5 packages in 60ms
Installed 7 packages in 15ms
 + anyio==4.6.2.post1
 + certifi==2024.8.30
 + h11==0.14.0
 + httpcore==1.0.7
 + httpx==0.28.0
 + idna==3.10
 + sniffio==1.3.1
➜  uv git:(pip-uninstall--dry-run) ./target/debug/uv pip uninstall --dry-run httpx
Would uninstall 1 package
 - httpx==0.28.0
➜  uv git:(pip-uninstall--dry-run) ./target/debug/uv pip list                     
Package  Version
-------- -----------
anyio    4.6.2.post1
certifi  2024.8.30
h11      0.14.0
httpcore 1.0.7
httpx    0.28.0
idna     3.10
sniffio  1.3.1
```

---------

Co-authored-by: Charlie Marsh <[email protected]>
@moreati moreati closed this as completed in #5 Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants