You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I give my Python script a name that clashes with a module name in my Python environment, the RunPython() function loads the named module from the environment instead of my script. Normally Python looks for module imports in the current directory first, and then the system path.
To reproduce
Set up a minimal Conda Python 3.6 environment and install xlwings. Note that even in this mininal environment the module test exists in the environment's lib directory.
Create a new xlwings project called test: xlwings quickstart test --standalone
Open test.xlsm, rename the _xlwings.conf sheet to xlwings.conf and set the Interpreter to point to the environment created in step 1 (e.g. C:\Users\Ian\AppData\Local\conda\conda\envs\temp\pythonw.exe)
Execute the SampleCall() VBA macro.
Expected result: Script runs and writes Hello xlwings! to cell A1.
Actual result:
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: module 'test' has no attribute 'hello_xlwings'
Workaround
Edit the VBA code in the xlwings module: Instead of sys.path.extend(...), which puts the user script directory at the end of the path, do sys.path[0:0] = ..., which puts the user script directory first in the path.
The text was updated successfully, but these errors were encountered:
Windows 10, xlwings version 0.12.1
When I give my Python script a name that clashes with a module name in my Python environment, the RunPython() function loads the named module from the environment instead of my script. Normally Python looks for module imports in the current directory first, and then the system path.
To reproduce
xlwings
. Note that even in this mininal environment the moduletest
exists in the environment'slib
directory.xlwings quickstart test --standalone
SampleCall()
VBA macro.Expected result: Script runs and writes
Hello xlwings!
to cell A1.Actual result:
Traceback (most recent call last):
Workaround
Edit the VBA code in the xlwings module: Instead of
sys.path.extend(...)
, which puts the user script directory at the end of the path, dosys.path[0:0] = ...
, which puts the user script directory first in the path.The text was updated successfully, but these errors were encountered: