Warm tip: This article is reproduced from serverfault.com, please click

How do I configure PATH variables so I can run packages on the CLI?

发布于 2019-03-01 05:01:54

I have Python 3.7 installed on my Mac and installed the package pipreqs with the command pip3 install pipreqs --user.

When I try to run pipreqs path/to/file I get an -bash: pipreqs: command not found error.

I get that it's looking in the wrong place, which is why the package can't be found.

I've been seeing a few posts like this helping people reset their paths. I really have no idea where to start. Is this something I can just do from the command line, or do I actually have to edit a file using vim or something. Do I ~/.bashrc directly?

When I run run echo $path I get

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/dev/opt/bin:/Users/dev/opt/bin:/Users/dev/dev/bin:/Users/dev/.local/bin My username is dev.

EDIT:

$ pip3 show -f pipreqs | grep /pipreqs
Home-page: https://github.com/bndr/pipreqs
  ../../../bin/pipreqs
  pipreqs/__pycache__/pipreqs.cpython-37.pyc
  pipreqs/pipreqs.py
Questioner
bones225
Viewed
0
bones225 2019-03-06 09:06:01

This was the fix:

$ open ~/.bash_profile

Then, in the editor,

export PATH="/Users/<my-username>/Library/Python/<python-edition>/bin:$PATH"

Then save the editor (with ctrl-s).

Then you need to 'activate' the .bash_profile using source. I believe you can also just close and reopen terminal.

$ source ~/.bash_profile

pipreqs now works as a command.