Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require to set the PYTHONPATH when working with OneDrive #1275

Closed
RobertvanLoon opened this issue Mar 13, 2020 · 20 comments · Fixed by #1462
Closed

Don't require to set the PYTHONPATH when working with OneDrive #1275

RobertvanLoon opened this issue Mar 13, 2020 · 20 comments · Fixed by #1462
Milestone

Comments

@RobertvanLoon
Copy link

RobertvanLoon commented Mar 13, 2020

Windows 10, xlwings 0.17.1, Office 365, Python 3.7

Until yesterday my xlwings was working perfectly fine. This morning when I opened up the same spreadsheet I worked on the night before I got this error message:

ModuleNotFoundError: No module named 'Options_Pricer_RvL'
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\rober\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
    module = import_module(module_name)
  File "C:\Users\rober\Anaconda3\lib\site-packages\xlwings\udfs.py", line 228, in get_udf_module
    module = get_udf_module(module_name)
  File "C:\Users\rober\Anaconda3\lib\site-packages\xlwings\udfs.py", line 447, in import_udfs
    return ToVariant(getattr(obj, method)(*pargs, **kwargs))
  File "C:\Users\rober\Anaconda3\lib\site-packages\xlwings\server.py", line 194, in Call
    return func(*args)
  File "C:\Users\rober\Anaconda3\lib\site-packages\win32com\server\policy.py", line 586, in _invokeex_
    return S_OK, -1, self._invokeex_(dispid, lcid, wFl

I did not change anything to any settings. The same issue appears on my desktop and my laptop. I've tried different sheets, all have the same problem. I am 100% sure the spreadsheet has the same name, and is in the same location, as the corresponding .py file.

Any idea what is going on? Help is much appreciated!

Thanks.

@fzumstein
Copy link
Member

Does a quickstart sample work?

@RobertvanLoon
Copy link
Author

RobertvanLoon commented Mar 15, 2020

Strangely enough a new clean sheet starting with udfs from scratch does work. But any existing sheet does not. Also not the 4 xlwings examples.

@fzumstein
Copy link
Member

Do you have a value for UDF Modules in your add-in or config?

@RobertvanLoon
Copy link
Author

Do you mean xlwings_udfs module in my spreadsheet? Yes, see pic.

afbeelding

The problem is not just with UDFs. Also matplotlib plots don't work anymore.

@RobertvanLoon
Copy link
Author

I did some more testing and even a brand new workbook and .py file (with same name and location) gives me the same error message now. I have not done any updates to my Windows or Office that I am aware of.

Are there other things I can do to help finding to find the source of this problem?

@fzumstein
Copy link
Member

What I actually meant is to doulbe check your config in the Ribbon and/or config files: https://docs.xlwings.org/en/stable/addin.html

@RobertvanLoon
Copy link
Author

I have not changed my configuration in the Ribbon since I start using xlwings. I double checked but all locations are correct. UDFs used to work without specifying the UDF modules in the Ribbon. I did try to specify it explicitly but that didn't help. This is my .xlwings\xlwings.conf file if that helps:

"C:\Users\rober\Anaconda3\python.exe",""
"C:\Users\rober\Anaconda3\python.exe",""
"INTERPRETER",""
"CONDA ENV","base"
"LOG FILE",""
"USE UDF SERVER","False"
"DEBUG UDFS","False"
"PYTHONPATH","C:\Users\rober\Anaconda3\python.exe"
"CONDA BASE","C:\Users\rober\Anaconda3"
"UDF MODULES",""

@RobertvanLoon
Copy link
Author

Looks like I found the issue, it seems to have something to do with Onedrive. Since I've moved my files from Onedrive to my local C: drive, everything works fine again. After moving them back to Onedrive, same problems. This is quite annoying as I use Onedrive all the time to use files on both my laptop and desktop.

Any idea what I need to change to Onedrive to get this fixed?

@fzumstein
Copy link
Member

Can you please check if you get the same behaviour with 0.18? You will need to upgrade both the add-in and the Python package.

@RobertvanLoon
Copy link
Author

RobertvanLoon commented Mar 17, 2020 via email

@fzumstein
Copy link
Member

you are on anaconda so might have installed xlwings previously via conda? best would be to clean up first via pip uninstall xlwings and conda remove xlwings, then try again with conda install -c conda-forge xlwings.

@RobertvanLoon
Copy link
Author

RobertvanLoon commented Mar 17, 2020 via email

@fzumstein
Copy link
Member

One thing I noticed is that your config file looks a bit funny, i.e. wrong e.g. with the PYTHONPATH. Can you cut it down to the following:

"CONDA ENV","base"
"CONDA BASE","C:\Users\rober\Anaconda3"

and try again?

@RobertvanLoon
Copy link
Author

RobertvanLoon commented Mar 17, 2020 via email

@fzumstein
Copy link
Member

While you can install them with PyCharm, you will always install them into one of the conda environments. Are they installed in the base environment where you are pointing xlwings to?

@RobertvanLoon
Copy link
Author

RobertvanLoon commented Mar 17, 2020 via email

@fzumstein
Copy link
Member

Actually, for now you'll need to set the PYTHONPATH when you use OneDrive to something like %ONEDRIVE%\yourproject.

@fzumstein
Copy link
Member

or if you are on business: %ONEDRIVECOMMERCIAL%\yourproject

@RobertvanLoon
Copy link
Author

RobertvanLoon commented Mar 18, 2020 via email

@fzumstein fzumstein changed the title Yesterday no problems, today ModuleNotFoundError OneDrive document the usage of PYTHONPATH Mar 18, 2020
@fzumstein fzumstein added the docs label Mar 18, 2020
@fzumstein
Copy link
Member

I must have thought it's obvious when I fixed it, but it's obviously not - will try to document that soonish.

@fzumstein fzumstein added this to the 0.18.1 milestone Mar 18, 2020
@fzumstein fzumstein modified the milestones: 0.19.0, 0.19.1, 0.19.2 May 2, 2020
@fzumstein fzumstein modified the milestones: 0.19.2, 0.19.3 May 11, 2020
@fzumstein fzumstein removed this from the 0.19.3 milestone May 19, 2020
@fzumstein fzumstein added this to the 0.20.9 milestone Nov 2, 2020
@fzumstein fzumstein changed the title OneDrive document the usage of PYTHONPATH Don't require to set the PYTHONPATH when working with OneDrive Nov 2, 2020
@fzumstein fzumstein added enhancement and removed docs labels Nov 2, 2020
@fzumstein fzumstein modified the milestones: 0.21.0, 0.21.1, 0.21.2 Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants