Import python package from local directory into interpreter

前端 未结 9 1842
野的像风
野的像风 2020-11-29 02:54

I\'m developing/testing a package in my local directory. I want to import it in the interpreter (v2.5), but sys.path does not include the current directory. Right now I type

9条回答
  •  旧巷少年郎
    2020-11-29 03:37

    A bit late to the party, but this is what worked for me:

    >>> import sys
    >>> sys.path.insert(0, '')
    

    Apparently, if there is an empty string, Python knows that it should look in the current directory. I did not have the empty string in sys.path, which caused this error.

提交回复
热议问题