简体   繁体   中英

How to access code outside of current folder directory?

I want to access my 'utils' folder that is outside of the current directory that my code is in. How do I access the files and functions within that file?

For example, I am trying to access functions in file_to_access.py from 00_label_data.py.

在此处输入图片说明

I tried doing this but it still is not working and says 'no module found'

在此处输入图片说明

What is the correct method for doing this method?

It's a little hard to tell from the screen shots, as the display isn't quite as descriptive as I've like. However, the main suspicion is at

... import file_to_access.py

There is no such module: the module name is merely file_to_access ; you supplied the file name. Also, I suspect that you will want

import mbl.code.utils.file_to_access

to properly activate your reference in line 8.

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