Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: deletion of item in sys.path is undone each time I restart the interpreter

>>> sys.path[6]
/path/to/django
>>> sys.path.pop(6)
/path/to/django

Then CTRL + D

$ python

>>> sys.path[6]
/path/to/django

O dear...

like image 905
Bentley4 Avatar asked Dec 11 '25 12:12

Bentley4


1 Answers

sys.path is populated from the externally maintained PYTHONPATH variable. Change this variable to get a permanent change when you restart python.

On unix (including Macs) when using bash it's configured most likely like this:

export PYTHONPATH=....

And this statement is most likely hiding in your .profile or .bashrc file.

To do this in Windows you need to do something like

SET PYTHONPATH=....

And it's probably somewhere in the system control panel - under environment.

If you want to see your current setting for PYTHONPATH, go to command (terminal) window and type echo $PYTHONPATH (unix) or echo %PYTHONPATH% (windows)

like image 195
Maria Zverina Avatar answered Dec 14 '25 02:12

Maria Zverina



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!