Skip to content
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

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

Closed
Fifiboss98 opened this issue Jul 22, 2021 · 9 comments
Closed

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

Fifiboss98 opened this issue Jul 22, 2021 · 9 comments
Labels
question Further information is requested

Comments

@Fifiboss98
Copy link

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.

@Fifiboss98 Fifiboss98 added the question Further information is requested label Jul 22, 2021
@ddelange
Copy link
Owner

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
Copy link
Author

Fifiboss98 commented Jul 22, 2021 via email

@Fifiboss98
Copy link
Author

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
Copy link
Owner

ddelange commented Jul 23, 2021

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
Copy link
Author

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
Copy link
Owner

ddelange commented Jul 23, 2021

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

Fifiboss98 commented Jul 26, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants