0

I have created a simple Python package and I have uploaded it to PyPI. I have added command scripts inside the setup.py file so that I can run the program at any point using my terminal. The thing is, when I install it via

pip3 install noty

typing noty doesnt work. On the other hand, installing it using sudo pip3 install noty works just fine. I know it is a PATH issue but I can't seem to find a solution at all. Is it possible for the program to be able to run without needing to install it using sudo? Here is the github link to the package: https://github.com/GrgBls/noty

Dustin Ingram
  • 20,502
  • 7
  • 59
  • 82
GrgBls
  • 5
  • 2
  • Is there an error when running `pip3 install noty`? If you type `echo $PATH` what do you currrently see? I use [pyenv](https://github.com/pyenv/pyenv) and [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv) for Python packages on macOS and Linux to avoid need of sudo and installing packages for all users, that generally helps with above. – MSK Feb 23 '20 at 09:48
  • no error at all – GrgBls Feb 23 '20 at 09:58
  • Try running `export PATH=$HOME/.local/bin:$PATH` after running `pip3 install noty` and then typing `noty` to see if that works? Make sure to run `sudo pip3 uninstall noty` first to avoid duplicate installations. – MSK Feb 23 '20 at 10:11
  • I'm guessing the package has been installed in your user site when not using `sudo`, same as running `pip3 install --user noty`, see reference: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site – MSK Feb 23 '20 at 10:13
  • If above works, you can fix the PATH issue permanently by following this example: https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix/14638025#14638025 – MSK Feb 23 '20 at 10:14

1 Answers1

0

When not using sudo and using the Python version coming with your operating system, pip3 might install packages to your user site because it doesn't have permissions to install packages globally for all users. This is same as if using pip3 install --user package.

To list binaries that have been installed in your user site under ~/.local directory:

ls ~/.local/bin

The user site is not added into your PATH by default. To fix this, you can add the following to your shell init file and reload the configuration:

export PATH=$HOME/.local/bin:$PATH

Put it somewhere towards the end of the file.

If you don't know how to edit the configuration, see example for modifying shell configuration when using Bash: How to permanently set $PATH on Linux/Unix?

More information about the user site in Python packaging documenation: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site

MSK
  • 84
  • 4