简体   繁体   中英

Cinema4D: How do I import/include/embed a user python script into another?

I would like to embed a script file full of often used defs into other script files. For example, I would like test.py to load the contents of defs.py (which is in the same folder) into itself in line.

When I try adding

import defs

into the body inside test.py I get error "No module named defs"

For anybody else facing this issue. Just add this on top of your script:

import sys
sys.path.append(os.path.dirname(__file__))

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