安装xlutils遇到的错误
最近在学习python,然后各种折腾。
系统用的windows8.1,python使用的是3.42版本,文本编辑使用notepad++,IDE使用pycharm 社区版。
python 配备pip和easy_install。
不过在安装xlutils的时候发生了一些不愉快。
主要是xlutils需要一些东西,而这些东西系统不能满足。
主要是xlutils 虽然说是可以在python3.x以上版本可以运行但是,xlwt有些问题,对应的python 3.x版本的xlwt是xlwt3(印象是这个),而实际上xlwt3早就不开发了,还不如xlwt呢,不过我发现了一个xlwt-future,所以动手改了一下xlutils的setup.py文件。
packages=['xlutils','xlutils.tests'],
zip_safe=False,
include_package_data=True,
install_requires=[
'xlrd >= 0.7.2',
'xlwt_future >= 0.7.4',
],
其中有这么一段,把xlwt改为了xlwt_future,所以后面安装就很顺利。
如果不这样,python一直报的错误是
from xlwt import __VERSION__
File "C:\Users\ADMINI~1\AppData\Local\Temp\pip_build_Administrator\xlwt\xlwt\_
_init__.py", line 3, in <module>
from Workbook import Workbook
ImportError: No module named 'Workbook'
另一个问题就是xlutils-1.7.1包中的setup.py中的第十四行,有一处
version=file(os.path.join(base_dir, name, 'version.txt')).read().strip(),
实际上python 3.42中file()的方法已经被去掉了,已经被open()方法取代
version=open(os.path.join(base_dir, name, 'version.txt')).read().strip(),
and it works!
so thats all!
D:\下载夹\xlutils-1.7.1\xlutils-1.7.1>pip install xlutils
Requirement already satisfied (use --upgrade to upgrade): xlutils in c:\python34
\lib\site-packages\xlutils-0.0.0-py3.4.egg
Requirement already satisfied (use --upgrade to upgrade): xlrd>=0.7.2 in c:\pyth
on34\lib\site-packages (from xlutils)
Downloading/unpacking xlwt>=0.7.4 (from xlutils)
Running setup.py (path:C:\Users\ADMINI~1\AppData\Local\Temp\pip_build_Administ
rator\xlwt\setup.py) egg_info for package xlwt
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "C:\Users\ADMINI~1\AppData\Local\Temp\pip_build_Administrator\xlwt\se
tup.py", line 4, in <module>
from xlwt import __VERSION__
File "C:\Users\ADMINI~1\AppData\Local\Temp\pip_build_Administrator\xlwt\xl
wt\__init__.py", line 3, in <module>
from Workbook import Workbook
ImportError: No module named 'Workbook'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "C:\Users\ADMINI~1\AppData\Local\Temp\pip_build_Administrator\xlwt\setup.
py", line 4, in <module>
from xlwt import __VERSION__
File "C:\Users\ADMINI~1\AppData\Local\Temp\pip_build_Administrator\xlwt\xlwt\_
_init__.py", line 3, in <module>
from Workbook import Workbook
ImportError: No module named 'Workbook'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in C:\Users\ADMINI~1\A
ppData\Local\Temp\pip_build_Administrator\xlwt
Storing debug log for failure in C:\Users\Administrator\pip\pip.log
D:\下载夹\xlutils-1.7.1\xlutils-1.7.1>setup.py install
running install
running bdist_egg
running egg_info
writing requirements to xlutils.egg-info\requires.txt
writing dependency_links to xlutils.egg-info\dependency_links.txt
writing xlutils.egg-info\PKG-INFO
writing entry points to xlutils.egg-info\entry_points.txt
writing top-level names to xlutils.egg-info\top_level.txt
reading manifest file 'xlutils.egg-info\SOURCES.txt'
writing manifest file 'xlutils.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
creating build\bdist.win32\egg
creating build\bdist.win32\egg\xlutils
copying build\lib\xlutils\copy.py -> build\bdist.win32\egg\xlutils
copying build\lib\xlutils\display.py -> build\bdist.win32\egg\xlutils
copying build\lib\xlutils\filter.py -> build\bdist.win32\egg\xlutils
copying build\lib\xlutils\license.txt -> build\bdist.win32\egg\xlutils
copying build\lib\xlutils\margins.py -> build\bdist.win32\egg\xlutils
copying build\lib\xlutils\save.py -> build\bdist.win32\egg\xlutils
copying build\lib\xlutils\styles.py -> build\bdist.win32\egg\xlutils
creating build\bdist.win32\egg\xlutils\tests
copying build\lib\xlutils\tests\date.xls -> build\bdist.win32\egg\xlutils\tests
copying build\lib\xlutils\tests\datetime.xls -> build\bdist.win32\egg\xlutils\te
sts
copying build\lib\xlutils\tests\fixtures.py -> build\bdist.win32\egg\xlutils\tes
ts
copying build\lib\xlutils\tests\ragged.xls -> build\bdist.win32\egg\xlutils\test
s
copying build\lib\xlutils\tests\sample.xlsx -> build\bdist.win32\egg\xlutils\tes
ts
copying build\lib\xlutils\tests\test.xls -> build\bdist.win32\egg\xlutils\tests
copying build\lib\xlutils\tests\testall.xls -> build\bdist.win32\egg\xlutils\tes
ts
copying build\lib\xlutils\tests\testnoformatting.xls -> build\bdist.win32\egg\xl
utils\tests
copying build\lib\xlutils\tests\test_copy.py -> build\bdist.win32\egg\xlutils\te
sts
copying build\lib\xlutils\tests\test_docs.py -> build\bdist.win32\egg\xlutils\te
sts
copying build\lib\xlutils\tests\test_filter.py -> build\bdist.win32\egg\xlutils\
tests
copying build\lib\xlutils\tests\test_save.py -> build\bdist.win32\egg\xlutils\te
sts
copying build\lib\xlutils\tests\test_styles.py -> build\bdist.win32\egg\xlutils\
tests
copying build\lib\xlutils\tests\test_view.py -> build\bdist.win32\egg\xlutils\te
sts
copying build\lib\xlutils\tests\__init__.py -> build\bdist.win32\egg\xlutils\tes
ts
copying build\lib\xlutils\version.txt -> build\bdist.win32\egg\xlutils
copying build\lib\xlutils\view.py -> build\bdist.win32\egg\xlutils
copying build\lib\xlutils\__init__.py -> build\bdist.win32\egg\xlutils
byte-compiling build\bdist.win32\egg\xlutils\copy.py to copy.cpython-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\display.py to display.cpython-34.py
c
byte-compiling build\bdist.win32\egg\xlutils\filter.py to filter.cpython-34.pyc
File "build\bdist.win32\egg\xlutils\filter.py", line 699
print repr(self.name),
^
SyntaxError: invalid syntax
byte-compiling build\bdist.win32\egg\xlutils\margins.py to margins.cpython-34.py
c
File "build\bdist.win32\egg\xlutils\margins.py", line 70
print fname
^
SyntaxError: Missing parentheses in call to 'print'
byte-compiling build\bdist.win32\egg\xlutils\save.py to save.cpython-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\styles.py to styles.cpython-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\tests\fixtures.py to fixtures.cpyth
on-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\tests\test_copy.py to test_copy.cpy
thon-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\tests\test_docs.py to test_docs.cpy
thon-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\tests\test_filter.py to test_filter
.cpython-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\tests\test_save.py to test_save.cpy
thon-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\tests\test_styles.py to test_styles
.cpython-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\tests\test_view.py to test_view.cpy
thon-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\tests\__init__.py to __init__.cpyth
on-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\view.py to view.cpython-34.pyc
byte-compiling build\bdist.win32\egg\xlutils\__init__.py to __init__.cpython-34.
pyc
creating build\bdist.win32\egg\EGG-INFO
copying xlutils.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO
copying xlutils.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO
copying xlutils.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO
copying xlutils.egg-info\entry_points.txt -> build\bdist.win32\egg\EGG-INFO
copying xlutils.egg-info\not-zip-safe -> build\bdist.win32\egg\EGG-INFO
copying xlutils.egg-info\requires.txt -> build\bdist.win32\egg\EGG-INFO
copying xlutils.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO
creating 'dist\xlutils-1.7.1-py3.4.egg' and adding 'build\bdist.win32\egg' to it
removing 'build\bdist.win32\egg' (and everything under it)
Processing xlutils-1.7.1-py3.4.egg
creating c:\python34\lib\site-packages\xlutils-1.7.1-py3.4.egg
Extracting xlutils-1.7.1-py3.4.egg to c:\python34\lib\site-packages
File "c:\python34\lib\site-packages\xlutils-1.7.1-py3.4.egg\xlutils\filter.py"
, line 699
print repr(self.name),
^
SyntaxError: invalid syntax
File "c:\python34\lib\site-packages\xlutils-1.7.1-py3.4.egg\xlutils\margins.py
", line 70
print fname
^
SyntaxError: Missing parentheses in call to 'print'
Removing xlutils 0.0.0 from easy-install.pth file
Adding xlutils 1.7.1 to easy-install.pth file
Installing margins-script.py script to C:\Python34\Scripts
Installing margins.exe script to C:\Python34\Scripts
Installing margins.exe.manifest script to C:\Python34\Scripts
Installed c:\python34\lib\site-packages\xlutils-1.7.1-py3.4.egg
Processing dependencies for xlutils==1.7.1
Searching for xlwt-future==0.8.0
Best match: xlwt-future 0.8.0
Processing xlwt_future-0.8.0-py3.4.egg
xlwt-future 0.8.0 is already the active version in easy-install.pth
Using c:\python34\lib\site-packages\xlwt_future-0.8.0-py3.4.egg
Searching for xlrd==0.9.3
Best match: xlrd 0.9.3
Adding xlrd 0.9.3 to easy-install.pth file
Using c:\python34\lib\site-packages
Searching for future==0.14.3
Best match: future 0.14.3
Processing future-0.14.3-py3.4.egg
future 0.14.3 is already the active version in easy-install.pth
Installing futurize-script.py script to C:\Python34\Scripts
Installing futurize.exe script to C:\Python34\Scripts
Installing futurize.exe.manifest script to C:\Python34\Scripts
Installing pasteurize-script.py script to C:\Python34\Scripts
Installing pasteurize.exe script to C:\Python34\Scripts
Installing pasteurize.exe.manifest script to C:\Python34\Scripts
Using c:\python34\lib\site-packages\future-0.14.3-py3.4.egg
Finished processing dependencies for xlutils==1.7.1
D:\下载夹\xlutils-1.7.1\xlutils-1.7.1>
尽管仍然出现了一些小的错误,但是安装总算顺利的安装完毕,这些错误是小错误,不会中断,只是影响print或者什么小的函数而已。
版权声明:
作者:xinyu2ru
链接:https://www.rxx0.com/motion/an-zhuang-xlutils-yu-dao-di-cuo-wu.html
来源:RUBLOG-分享我的生活
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
东北黑木耳价格
不错 支持你 有时间到我那看看 欢迎回访。。。
likaci
这代码排版吊爆了…
用pip不能直接装吗?
likaci
刚试了下,win7x64 python2.7 下用 pip 无痛就装上了
👿 python3 什么的还是见鬼去吧,其实主要是ArcGIS 自带python2.7
xinyu2ru@likaci
对的,2.7轻松容易啊