如果没有文件系统路径,python脚本如何理解我引用的模块?
两者如何:
import a和:
import imp a = imp.load_source('a',r'C:\Users\dimitris\Desktop\PythonData\main.py')工作?
How does a python script understand to which module I refer to without file system path?
How can both:
import aand:
import imp a = imp.load_source('a',r'C:\Users\dimitris\Desktop\PythonData\main.py')work?
最满意答案
C-Python使用$ PYTHONPATH环境变量,该变量列出了模块的搜索位置。 通过订购此目录列表,您可以指示搜索顺序。 除此之外,还会搜索您调用python的本地目录。
其他发行版,如Anaconda和Enthough也使用其他搜索已安装软件包的方法。
C-Python uses the $PYTHONPATH environment variable which lists search locations for modules. By ordering this list of directories you indicate the search order. In addition to that, the local directory from which you called python is also searched.
Other distributions, such as Anaconda and Enthough use other methods of searching for installed packages as well.
如何在不使用系统路径的情况下了解模块在我的计算机中的位置?(How does python understand where a module is located in my computer without using system path?)如果没有文件系统路径,python脚本如何理解我引用的模块?
两者如何:
import a和:
import imp a = imp.load_source('a',r'C:\Users\dimitris\Desktop\PythonData\main.py')工作?
How does a python script understand to which module I refer to without file system path?
How can both:
import aand:
import imp a = imp.load_source('a',r'C:\Users\dimitris\Desktop\PythonData\main.py')work?
最满意答案
C-Python使用$ PYTHONPATH环境变量,该变量列出了模块的搜索位置。 通过订购此目录列表,您可以指示搜索顺序。 除此之外,还会搜索您调用python的本地目录。
其他发行版,如Anaconda和Enthough也使用其他搜索已安装软件包的方法。
C-Python uses the $PYTHONPATH environment variable which lists search locations for modules. By ordering this list of directories you indicate the search order. In addition to that, the local directory from which you called python is also searched.
Other distributions, such as Anaconda and Enthough use other methods of searching for installed packages as well.
发布评论