Where should I put my own python module so that it can be imported

后端 未结 6 1812
心在旅途
心在旅途 2020-11-29 16:53

I have my own package in python and I am using it very often. what is the most elegant or conventional directory where i should put my package so it is going to be imported

6条回答
  •  眼角桃花
    2020-11-29 17:38

    I usually put the stuff i want to have ready to import in the user site directory:

    ~/.local/lib/pythonX.X/site-packages
    

    To show the right directory for your platform, you can use python -m site --user-site


    edit: it will show up in sys.path once you create it:

    mkdir -p "`python -m site --user-site`"
    

提交回复
热议问题