ImportError: No Module named xlwt

走远了吗. 提交于 2019-12-10 02:04:14

问题


My sytem: Windows, Python 2.7

I downloaded a package and want to include it in my script.

After I unzipped the package, here is my folder structure:

  • Work
    • xlwt-0.7.3 (contains a setup.py)
      • xlwt (contains __init__.py among others)

My script runs from the top-level (Work) folder.

Using import xlwt in my script produces:

ImportError: No Module named xlwt

How do I import xlwt?


回答1:


First off, try using easy_install or pip to install it into your pythonpath:

easy_install xlwt

or

pip install xlwt

These are python package managers/installers and make the whole process so much easier. But if you have already downloaded it manually, you still need to install it:

python setup.py install

Then it will be available in your python path for import. If you find that you don't have easy_install, manually download this: http://peak.telecommunity.com/dist/ez_setup.py and do python ez_setup.py, and then continue the instructions. Best choice though is to install pip and use it for your package installations. If you have easy_install, but not pip, you can do easy_install pip




回答2:


C:\Users\xxxxxxx\AppData\Local\Programs\Python\Python37\Scripts>pip install xlwt
Collecting xlwt
Downloading https://files.pythonhosted.org/packages/44/48/def306413b25c3d01753603b1a222a011b8621aed27cd7f89cbc27e6b0f4/xlwt-1.3.0-py2.py3-none-any.whl (99kB)
    100% |████████████████████████████████| 102kB 339kB/s
Installing collected packages: xlwt
Successfully installed xlwt-1.3.0


来源:https://stackoverflow.com/questions/9848299/importerror-no-module-named-xlwt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!