excelpython icon indicating copy to clipboard operation
excelpython copied to clipboard

Py.Builtin: No module named `__builtin__` & `xlfunc` name changed to `xlsub` name

Open JohnnySG opened this issue 9 years ago • 4 comments

When I Py.Call Py.Builtin module, there is an Importerror: No module named __builtin__ . My python version is Python3.4. In file xlpyserver.py, line 191, I change: import __builtin__ to: import builtins because I use version 3, however it doesn't work. How can I fix it, please?

JohnnySG avatar Aug 06 '15 04:08 JohnnySG

Hi,

Thanks for reporting this: indeed the __builtin__ module has been renamed builtins in Python 3, so in order for xlpyserver.py to be compatible with both 2 and 3 it should check the Python version and act accordingly.

However I do not understand why your fix does not work? Did you try restarting Excel or at least Python? The xlpyserver.py file does not get reloaded automatically upon changes.

Regards,

Eric

ericremoreynolds avatar Aug 07 '15 11:08 ericremoreynolds

Dear Eric,

Thank you for your work! Although I have restarted Excel, the error still exists. So, I have to change Python 3 to Python 2.

And I find another problem: For example,

  1. I change the name of a function to another name ( i.e. A --> B ) in file.py;
  2. Then Import Python UDFs;
  3. Save Excel file.xlsm and restart it;
  4. Turn to Excel Develop Tab --> Marco, I find the deleted function name A appears as a macro A, and I can't delete it because the Delete button is greyed out.

Software Version:

  • Excel 2013 64bit
  • Python 2.7.10 32bit
  • Excelpython 2.0.8

I want to know how to delete the name A ( which is originally the name of a function defined by xlfunc ) in Macro list.

Regards,

Johnny

JohnnySG avatar Aug 08 '15 03:08 JohnnySG

Hey Eric this may be unrelated but... Besides having to pull a Microsoft reset every now and then (restart Excel to reflect changes), I often find myself having to delete a bunch of .pyc's... is that not avoidable programatically?

sergiolucero avatar Aug 08 '15 14:08 sergiolucero

I guess it's possible that that is what is causing the problem, but I think it's unlikely.

The .pyc's are just a feature of Python and not specifically related to ExcelPython - after all the process that ExcelPython launches is just a normal Python process, it really does not have anything special about it.

I have noticed in the past that sometimes .pyc's remain hanging on disk for some reason and don't get regenerated even though the corresponding .py source has changed (e.g. it has sometimes happened to me when using Git, which I guess plays around with file modification timestamps). Given that Python is supposed to take care of .pyc's already and the problem is a generic one, I would be hesitant to add any feature to ExcelPython which tries to circumvent Python's handling of .pyc's.

ericremoreynolds avatar Aug 10 '15 09:08 ericremoreynolds