[英]python import module from different folder
I have the following folder structure:我有以下文件夹结构:
In this process_file.py
script I want to be able to import the class process_things.py
which is in the classes folder.在这个
process_file.py
脚本中,我希望能够导入位于 classes 文件夹中的 class process_things.py
。 Tried following method 3 in this blog but it doesn't seem to work: https://blog.finxter.com/python-how-to-import-modules-from-another-folder/在此博客中尝试了以下方法 3,但它似乎不起作用: https://blog.finxter.com/python-how-to-import-modules-from-another-folder/
I have noticed that if I put the process_file.py
file outside the jobs folder and run from classes import process_file
then it works fine, but ideally I really want the file to be in the jobs folder.我注意到,如果我将
process_file.py
文件放在作业文件夹之外并from classes import process_file
运行,那么它工作正常,但理想情况下我真的希望该文件位于作业文件夹中。
did you check sys lib?你检查过系统库吗? a quick way like this:
像这样的快速方法:
import sys
sys.path.append('/path_to_your_project_folder/src/databricks/classes')
import process_things
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.