Basically pip installs the packages under its related python directory, in a directory called site-packages
(most likely, I'm not a python expert tbh). This is not included in the path you provided. First, ask pip to show the location to the package:
pip show openai
The output would be something like this:
Name: openai
Version: 0.22.0
Summary: Python client library for the OpenAI API
Home-page: https://github.com/openai/openai-python
Author: OpenAI
Author-email: [email protected]
License:
Location: /Users/<USER>/DIR/TO/SOME/PYTHON/site-packages
Requires: numpy, openpyxl, pandas, pandas-stubs, requests, tqdm
Required-by:
So your package will be available in
/Users/<USER>/DIR/TO/SOME/PYTHON/site-packages/openai
Either add /Users/<USER>/DIR/TO/SOME/PYTHON/site-packages/
to your path, or use the complete address to your package, or try to access it using your python:
python -m openai # -m stands for module
To get more information about the -m
flag, run python --help
.
Update
So as you mentioned in the comments, you get permission denied
after you add the directory to your package. This actually means that the package exists, but it's not permitted by your OS to execute. This is the thing you have to do, locate your package, and then:
sudo chmod +x /PATH/TO/script
And the reason you're getting command not found
after you use sudo directly with the package, is that you update your path variable in zsh
, but when you use sudo
, superuser uses sh
instead of zsh
.
openai
from the shell, and why should it work? This is a Python package, it is not meant to be run from the shell! – Currey