Skip to content

xlwings not working with OneDrive when the modules full folder location has a '-' in it #1891

@zecaclasher

Description

@zecaclasher

macOS Monterey / xlwings 0.27.5 / Excel Office 365 / Python 3.9.7


I managed to locally run a macro successfully but I am having issues to run the same macro from OneDrive. I just copied and pasted the excel file and the python files, nothing changed.

On troubleshooting, I noticed that if the local folder containing the python files includes a '-' in its name, I get a modulenotfound error even if it was normally working before. However, if I replace the '-' by a '_', it works normally.

It happens that OneDrive changed its location from /Users/abc/OneDrive (xlwings used to work fine) to /Users/abc/Library/CloudStorage/OneDrive-Personal/ which contains a '-' and now I'm getting this modulenotfound error.

I found a workaround which is to add the python folder to the PYTHONPATH in the addin - inside Excel- but it has some side effects as this environment variable is global and shared among all the workbooks. So, everytime I open a different workbook, I need to update PYTHONPATH.

Before, each workbook had its own xlwings.conf with its own PYTHONPATH and I had to set it up once instead of everytime I open another different workbook.

I have tried several solutions from previous issues in github and stackoverflow but had no luck.

Any ideas on how to troubleshoot it further?

Thanks in advance

I knew this time would come, I've updated all my workbooks removing formulas and vba macros and replacing them with Python code. I am now totally dependent on xlwings!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions