Hey everyone I installed Python3.9 on my Mac using homebrew package manager but now I do not know how to install packages to it for use
Can anyone please tell me, thanks !
You should first do some research on the Python virtual environment, but the final answer to your question is to use pip install
for installing Python packages. Be aware that there are other options out there, but pip
is the most prevalent.
When you installed python, it has pip installed by default. pip comes with python. You can check pip version by
pip --version
OR pip3 --version
Now, in order to install any other package, you can install by
pip install <package-name>
It would be better if you install a virtual environment, and install all other packages inside the virtual environment so that you can install packages according to your project requirements and with different versions.
To install virtual environment, do
pip install virtualenv
Once the virtual environment is installed, you can create your virtualenv according to your project requirement by:
virtualenv -p python3 venv
Here venv
is your virtualenv name. To activate it,
source venv/bin/actiavte
Now, you can install all your required packages inside this virtualenv by pip3 install <package-name>
. This will keep it separated from your system environment.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.