Where is the Default Python Path?

ViaByte.Net

Default Python Path on macOS and Linux

On macOS and Linux, the default Python path is slightly different. Python looks for modules and packages in several locations, including:

  • /usr/local/lib/pythonX.Y/site-packages
  • /usr/lib/pythonX.Y/site-packages
  • ~/.local/lib/pythonX.Y/site-packages

X.Y represents the version of Python you are using (e.g. 3.9). You can also modify the default Python path by adding directories to the PYTHONPATH environment variable.

Modifying the Python Path

If you need to modify the default Python path, you can do so by adding directories to the PYTHONPATH environment variable. This variable is a list of directories that Python searches for modules and packages.

Bagikan:

Tinggalkan komentar