简体   繁体   中英

how to place “.py” file into the search path of your python installation

I have two files say Geometry.py and PeptideBuilder.py for their installation They need to be placed into the search path of my python installation on ubuntu linux machine.

how can I know the search path of my python installation and how can I place them .

If you use this for a project, update python path in your main script:

import sys
sys.path.insert(0, '.path/to/folder/with/scripts')

If you need them for any instance of python, you should have sudo rights and put them in site-packages(check first PYTHONPATH for your py version):

import sys
print(sys.path)

Usual, the standard module path is like „/usr/lib/pythonX.Y/site-packages”. (that's standard in my Arch, but may be different on Ubuntu, that's way is better to check)

EDIT: if scripts are strictly related to your project, just puthem on same level with script that import's them, but I think you allready do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM