Import python package from local directory into interpreter

前端 未结 9 1851
野的像风
野的像风 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:40

    Using sys.path should include current directory already.

    Try:

    import .
    

    or:

    from . import sth
    

    however it may be not a good practice, so why not just use:

    import mypackage
    

提交回复
热议问题