I need to import classes from xlwt
module, accordingly I have tried getting error. Why so? Can you guide me here?
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Matty>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from xlwt import easyxf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named xlwt
>>> from xlwt import Workbook
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named xlwt
>>>
EDIT
C:\Users\matt>easy_install xlwt
Searching for xlwt
Best match: xlwt 0.7.4
Processing xlwt-0.7.4-py2.7.egg
Adding xlwt 0.7.4 to easy-install.pth file
Using c:\python27\lib\site-packages\xlwt-0.7.4-py2.7.egg
Processing dependencies for xlwt
Finished processing dependencies for xlwt
C:\Users\matt>
EDIT1
As per the comments from @Ab it works.
But why I need to import sys ?
C:\Users\matt>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'C:\\Python27\\lib\\site-packages\\beautifulsoup4-4.1.3-py2.7.egg', 'C:\\Py
thon27\\lib\\site-packages\\selenium-2.28.0-py2.7.egg', 'C:\\Python27\\lib\\site
-packages\\xlwt-0.7.4-py2.7.egg', 'C:\\Windows\\system32\\python27.zip', 'C:\\Py
thon27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27
\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']
>>> from xlwt import easyxf
>>> from xlwt import Workbook
>>> from xlwt import *
>>>
You can run import sys ; sys.path
import sys ; sys.path
and see if c:\\python27\\lib\\site-packages\\
is in your path list. If it is, then again try run from xlwt import easyxf
You clearly don't have xlwt
installed, or Python doesn't know that you do.
Try running pip install xlwt
.
You can also look to see where physically the code for xlwt
is, and then add that file directory to your PYTHONPATH
so that Python will know to look there for the module.
This could be because you're running your code from a virtualenv
that does not have xlwt
installed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.