Importing in Python

前端 未结 4 1512
南旧
南旧 2020-12-20 04:27

In Python 2.5, I import modules by changing environment variables. It works, but using site-packages does not. Is there another way to import modules in directories other

4条回答
  •  Happy的楠姐
    2020-12-20 04:52

    On way is with PYTHONPATH environment variable. Other one is to add path to sys.path either directly by sys.path.append(path) or by defining .pth files and add them to with site.addsitedir(dirWithPths). Path files (.pth) are simple text files with a path in each line. Every .pth file in dirWithPths will be read.

提交回复
热议问题