importing xlwings module into python 3.4

2019-02-23 08:39发布

问题:

I'm trying to use the new excel integration module xlwings It works like a charm under Anaconda 2.0 for python 2.7 but I'm getting this error under Anaconda 2.0 for python 3.4 the xlwings file does contain class Workbook so I don't understand why it can't import it when I simply use the xlwings file in my project for 3.4 it works just fine

File "C:\Users\xxxxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\xlwings__init__.py", line 1, in from xlwings import Workbook, Range, Chart, version

ImportError: cannot import name 'Workbook'

回答1:

In "C:\Users\xxxxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\xlwings__init__.py"

Try changing from xlwings import Workbook, Range, Chart, __version__

to from xlwings.xlwings import Workbook, Range, Chart, __version__