Eggs in path before PYTHONPATH environment variable

前端 未结 3 1171
长情又很酷
长情又很酷 2020-12-28 18:08

If I have packages installed from easy_install, the eggs are prepended to sys.path before the items in the PYTHONPATH variable.

Fo

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-28 18:40

    I have done something like the following to prepend to the system path when running a top-level python executable file:

    import sys
    sys.path = [""] + sys.path
    

    Often, the "" for me involves use of the __file__ attribute to do relative look up for a path that includes the top-level module for my project. This is not recommended for use in producing, eggs, though I don't seem to mind the consequences. There may be another alternative to __file__.

提交回复
热议问题