xlwings UDFS: how to set PythonPath/ UDF_Modules c

2019-04-16 03:05发布

Thank you for your time first!

Recently I have been trying to build my own excel functions by using Xlwings. Unlike using

$ xlwings quickstart myproject 

which would create a python script in the same directory as the excel xlsm file, I would love to put the python script anywhere I want, like "D:\test0.py", so I did this on VBA Function Settings:

PYTHONPATH = "D:\test0.py"
UDF_MODULES = "test0"

Except the two lines above, I didn't change anything in Function Settings. However, what I got is only: errors, No module named 'test0'

I am now fully confused, what should I do if I want to import module from "D:\test0.py" correctly? I know this might be a stupid question, but I really need help now.

Thanks again!

1条回答
Melony?
2楼-- · 2019-04-16 03:36

PYTHONPATH, as the name says, is a path, not a file, i.e. you should be using

PYTHONPATH = "D:\"

xlwings quickstart myproject is still useful because it sets up the Excel file with the VBA module, even if you want to move out the python file later on.

查看更多
登录 后发表回答