You can also add directories with sys.path.append
, but I understand that this will be restored to its original state when the program ends.
I just want to make a code that I don't want to add again if I add it once, so could you tell me the related command?
windows python save pythonpath sys
Different operating systems work differently. As far as I know,
Add the following to ~/.bashrc
export PYTHONPATH="${PYTHONPATH}:/my/other/path"
If this doesn't work, you have to use a method to create a path configuration file.
python -m site --user-site
#2.7 Use the bottom one
python -c 'import site; site._script()' --user-site
on the path from here.Create a pth
file, and this .In the pth
file, write down the directory you want to add as path.
Go to the folder where you installed python and open Lib/site-packages
.
An empty file in this folder.Create a pth
and write down the path you want to add.
© 2024 OneMinuteCode. All rights reserved.