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

懵懂的女人 提交于 2019-12-08 02:01:38

问题


>>> 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...


回答1:


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)



来源:https://stackoverflow.com/questions/11667371/python-deletion-of-item-in-sys-path-is-undone-each-time-i-restart-the-interpret

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!