How to remove current directory from python import path

后端 未结 2 1888
盖世英雄少女心
盖世英雄少女心 2021-02-20 04:06

I want to work with the mercurial repository of hg itself. That is, I cloned Mercurial from https://www.mercurial-scm.org/repo/hg and want to run some hg

2条回答
  •  青春惊慌失措
    2021-02-20 04:47

    @ragol, i think Padraic has the correct solution. Within the python script that you are trying to run hg commands, you need to include the following command: sys.path.insert(0,"/usr/lib/pythonVERSION")

    Place the command at the very beginning of your python script. The command tells python to look in the /usr/lib/pythonVERSION directory first when importing modules.

    If that doesn't work, you may need to be more specific with the path. For example, if the module you are trying to import is located in the /usr/lib/pythonVERSION/site-packages/hg directory, you could use the following command: sys.path.insert(0,"/usr/lib/pythonVERSION/site-packages/hg")

提交回复
热议问题