Search code examples
pythonmacospip

Have problem to run Python command installed by pip in macOS Terminal


I'm not a Python user, so know little about Python. But I have to install stcgal using pip3 following its official guide.

pip3 install stcgal

However, if I run the installed command in terminal, it says zsh: command not found.

After a long searching, I find it was installed at /Users/myUserName/Library/Python/3.8/bin/. Though I can run the command with that path, it's very inconvenient. I wonder is there any way to run the code in any directory instead having to locate it explicitly?


Solution

  • You can create or edit your /Users/yimingliu/.zshrc file (if your macOS is older than macOS Catalina 10.15, then the file is /Users/yimingliu/.bash_profile), and add a line to add the python bin folder to your path:

    export PATH=/Users/yimingliu/Library/Python/3.8/bin:$PATH