CoderWanFeng/python-office

mac 安装后, 运行报错

xingguang2013 opened this issue · 1 comments

  1. 安装后
    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple python-office -U

  2. 执行
    office.excel.fake2excel(columns=['name', 'text'], rows=20)

  3. 报错

Traceback (most recent call last):
  File "/Users/xxx/work_code/python-lessons/main.py", line 9, in <module>
    import office
  File "/Users/xxx/work_code/python-lessons/venv/lib/python3.8/site-packages/office/__init__.py", line 1, in <module>
    from . import word
  File "/Users/xxx/work_code/python-lessons/venv/lib/python3.8/site-packages/office/word.py", line 12, in <module>
    from win32com.client import constants, gencache
ModuleNotFoundError: No module named 'win32com'
  1. 再次安装缺少的 win32
pip install pypiwin32
  1. 安装 win32 报错
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting pypiwin32
  Using cached https://mirrors.aliyun.com/pypi/packages/d0/1b/2f292bbd742e369a100c91faa0483172cd91a1a422a6692055ac920946c5/pypiwin32-223-py3-none-any.whl (1.7 kB)
  Using cached https://mirrors.aliyun.com/pypi/packages/2b/ca/5c086c18de8f70222787b3e824e755b68d99272531522e77bb381d4f60c8/pypiwin32-219.zip (4.8 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/2p/c0c3rrys09b8c8y0rrkscn8r0000gn/T/pip-install-b18sn648/pypiwin32_0e47d8d13683441e9c213f629f92a95f/setup.py", line 121
          print "Building pywin32", pywin32_version
                ^
      SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Building pywin32", pywin32_version)?
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

为什么 python-office自动化办公 不支持 mac 和 linux 系统?
👉https://mp.weixin.qq.com/s/Mv6xsBIEjzDy1u1peCFDQg