ddelange / pipgrip

Lightweight pip dependency resolver with deptree preview functionality based on the PubGrub algorithm
Other
180 stars 14 forks source link

This is not a bug!!! i am unable to execute pipgrip. #60

Closed Fifiboss98 closed 3 years ago

Fifiboss98 commented 3 years ago

I am on Ubuntu 20.04 LTS Python 3.8.10 pip 20.0.2

Issuing pipgrip --help throws me command not found. I have edited the .bashrc file by adding export PATH=/usr/local:$PATH And The path to site-packages file where pip modules are downloaded in my system.

But still getting the same output.

Please how can I run pipgrip need help.

ddelange commented 3 years ago

Which error do you get exactly? Is it a Python traceback (some ImportError or so)? Can you try which python, which pip and compare the two paths? Maybe your pip install pipgrip was using the system python version (2.7) with an old pip version messing up the console_scripts registration specified in the setup.py. Can you confirm import pipgrip works from py3.8? Alternatively, can you try python -m pipgrip --help? Maybe something went wrong with installing, and might be worth a shot re-installing with the pip of your python dist, e.g. python3.8 -m pip install --force-reinstall pipgrip

Hope that helps, please report back what fixed it :)

Fifiboss98 commented 3 years ago

Hello Thank you very much for replying so fast!

In fact the error I am getting is when I fire up my shell and then issuing pipgrip --help the output is pipgrip : command not found.

I am not on my computer right now. Will try tonight and give feedback.

Thanks

Le jeu. 22 juil. 2021 à 12:36, ddelange @.***> a écrit :

Which error do you get exactly? Is it a Python traceback (some ImportError or so)? Can you try which python, which pip and compare the two paths? Maybe your pip install pipgrip was using the system python version (2.7) with an old pip version messing up the console_scripts registration specified in the setup.py. Can you confirm import pipgrip works from py3.8? Alternatively, can you try python -m pipgrip --help? Maybe something went wrong with installing, and might be worth a shot re-installing with the pip of your python dist, e.g. python3.8 -m pip install --force-reinstall pipgrip

Hope that helps, please report back what fixed it :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ddelange/pipgrip/issues/60#issuecomment-884845039, or unsubscribe https://github.com/notifications/unsubscribe-auth/APIGQLYQP7GYERYVIQMLW23TY77C3ANCNFSM5AZM7SIA .

Fifiboss98 commented 3 years ago

I am back !! Input : which python Output : usr/bin/python

Import pipgrip works perfectly with Python 3.8

Input: python3.8 -m pip install --force-reinstall pipgrip Output: successfully installed pipgrip, setup tools... Etc

Now I type again pipgrip --help and I keep receiving the command not found message. Sorry

ddelange commented 3 years ago

Sounds like a PATH issue indeed: python3.8 (is in PATH) works, so in that case python3.8 -m pipgrip --help should also work (plz correct me if I'm wrong), and can function as temporary solution. So to me it seems that during your python installation process, not all paths were exposed to your shell, something that's usually stipulated in post-installation documentation. I for instance exclusively use pyenv to install and manage python versions and virtual environments. They provide a hook (in my case a bash hook in my .bash_profile) that takes care of pointing the shell to the right executables depending on the project I'm working on (similar to what direnv can do for you). It's one of many python managers, any of which should do the trick getting your paths consistent.

I will close as it's not an issue with pipgrip, however do feel free to follow up if necessary :)

Fifiboss98 commented 3 years ago

After installing pyenv and also direnv I try to reload pipgrip.

Input: python3.8 -m pipgrip --help

Output: /usr/bin/python3.8: No module named pipgrip.main; 'pipgrip' is a package and cannot be directly executed.

Any idea on what it means?

ddelange commented 3 years ago

My bad, the suggestion python -m pipgrip doesn't work (ref) as the command is currently only exposed under console_scripts. You really want a clean python set up so that you can trace back which paths are linked where, and why the executable pipgrip is not showing up in your terminal session.

So after you set up your shell to use python distributions that were installed using pyenv (the bash hook + installing python via pyenv, see link below), you can use pyenv global <version>, or a pyenv virtual environment created from one of the python versions you installed using pyenv. They will be put first in your PATH by the bash hook, and when you then use the pyenv-based pip to install pipgrip, all should start working as expected. Again many roads lead to Rome, pyenv is just my preferred tool to compile and run multiple python versions in a more or less sandboxed way. Apart from system python2.7 (which pyenv can completely overshadow during your terminal session using pyenv global and the bash hook), I have no other versions of python on my machine than pyenv python versions. This way I always know where to start debugging :)

See also https://github.com/ddelange/new-mac-setup#pyenv-and-pyenv-virtualenv for a quick start with pyenv

Fifiboss98 commented 3 years ago

Thanks for your feedback. In fact I mistakenly pip install all libraries in global environment causing some programs not running (to cite few : Argostranslate, pytts, pymarytts, etc). As they are already in my system I don't wanna re download everything ((yeah Internet is very expensive here!!)

So what I could certainly do without giving up is to somehow repackage every project and then install each in separate virtual env. My research fall on pipgrip as pip freeze doesn't work as expected.

Looks like my only option is to write a script where pipgrip should look inside my downloaded packages, build the dep tree for each project and print the output in a requirements.txt file.

I am wondering if it will work like that.

ddelange commented 3 years ago

pipgrip just calls pip in a subprocess, so if the packages are available to pip's cache mechanism, there should not be additional downloads. If you dont have the pip cache anymore, but only the distributions unpacked in the site-packages folder of python (venv), you should avoid pipgrip. I can suggest extracting from the local dist metadata for instance like:

pipdeptree --reverse --packages <your-installed-package> | grep '=='

Continuing on that thought: if you're really low on internet, you could go one step further and host your own pypi registry (e.g. devpi) on localhost, and let it cache anything it doesnt have yet (would mirror the official pypi). You can then pip install --index-url <localhost-url> ..., and so your local devpi will only talk to the internet if you're installing/requesting a package (version) that is not on your local registry yet. pipgrip supports --index-url as well, but of course the setup a bit overkill if this is a one time thing.

You can also install pipgrip via brew.sh, but it requires some setup of the brew package manager, and it will download/install latest python in the background upon brew install pipgrip, so I guess it's not a data saving option 😅

Good luck!

Fifiboss98 commented 3 years ago

Thanks, I'll check it out.

Le lun. 26 juil. 2021 à 10:38, ddelange @.***> a écrit :

pipgrip just calls pip in a subprocess, so if the packages are available to pip's cache mechanism, there should not be additional downloads. If you dont have the pip cache anymore, but only the distributions unpacked in the site-packages folder of python (venv), you should avoid pipgrip. I can suggest extracting from the local dist metadata for instance like:

pipdeptree --reverse --packages | grep '=='

Continuing on that thought: if you're really low on internet, you could go one step further and host your own pypi registry (e.g. devpi) on localhost, and let it cache anything it doesnt have yet (would mirror the official pypi). You can then pip install --index-url ..., and so your local devpi will only talk to the internet if you're installing/requesting a package (version) that is not on your local registry yet. pipgrip supports --index-url as well, but of course the setup a bit overkill if this is a one time thing.

You can also install pipgrip via brew.sh, but it requires some setup of the brew package manager, and it will download/install latest python in the background upon brew install pipgrip, so I guess it's not a data saving option 😅

Good luck!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ddelange/pipgrip/issues/60#issuecomment-886543337, or unsubscribe https://github.com/notifications/unsubscribe-auth/APIGQL7BB2Q2DG722U4AXB3TZUUHTANCNFSM5AZM7SIA .