windows下安装Python的XlsxWriter模块方法

yipeiwu_com5年前Python基础

在windows环境下安装python的XlsxWriter模块,虽然很简单,但由于自己粗心,少了一个字符,导致不少的错误。。。

1、通过pip命令来安装。

C:\Users\Administrator>pip install XlsWriter 
Collecting XlsWriter 
 Could not find a version that satisfies the requirement XlsWriter (from versions: ) 
No matching distribution found for XlsWriter 
You are using pip version 7.1.2, however version 8.1.1 is available. 
You should consider upgrading via the 'python -m pip install --upgrade pip' command. 

2、误以为是由于pip的版本太低,所以根据错误信息中的提示,更新pip

其中可以看到,会先下载,然后检测到有先前的版本,所以会先卸载,最后安装新版本的pip。

C:\Users\Administrator>python -m pip install --upgrade pip 
Collecting pip 
 Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB) 
 100% |████████████████████████████████| 1.2MB 61kB/s 
Installing collected packages: pip 
 Found existing installation: pip 7.1.2 
 Uninstalling pip-7.1.2: 
  Successfully uninstalled pip-7.1.2 
Successfully installed pip-8.1.1 

3、再次尝试安装,还是报错,觉得很奇怪,到底是什么地方错了,仔细看了一下,才发现是犯了低级错误鄙视,应该是 XlsxWriter 而不是XlsWriter,就是少了一个字符x导致报错:找不到要求安装的XlsWriter的一个版本。

C:\Users\Administrator>pip install XlsWriter 
Collecting XlsWriter 
 Could not find a version that satisfies the requirement XlsWriter (from versions: ) 
No matching distribution found for XlsWriter 

4、这次总算下载成功,并安装了大笑。

C:\Users\Administrator>pip install XlsxWriter 
Collecting XlsxWriter 
 Downloading XlsxWriter-0.8.6-py2.py3-none-any.whl (134kB) 
 100% |████████████████████████████████| 143kB 26kB/s 
Installing collected packages: XlsxWriter 
Successfully installed XlsxWriter-0.8.6 

5、另一种方法是,通过eays_install来安装XlsxWriter模块。

C:\Users\Administrator>easy_install XlsxWriter 
Searching for XlsxWriter 
Best match: XlsxWriter 0.8.6 
Adding XlsxWriter 0.8.6 to easy-install.pth file 
 
Using c:\python27\lib\site-packages 
Processing dependencies for XlsxWriter 
Finished processing dependencies for XlsxWriter 

6、接下来验证一下,是否安装成功。

这里打开cmd,输入python,这样就进入到python的交互环境。

最简单的方法就是 import 这个模块,如果没报错,就说明安装成功了。

这里特别要强调的是虽然上面的模块名称是XlsxWriter,但是在这里import时,都是小写的xlsxwriter,只要有一个字符不同,就会报错。

C:\Users\Administrator>python 
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import xlsxwriter 
>>> 

不得不说,安装python的各种模块,非常的方便,很赞大笑

关于XlsxWriter模块的详细参考信息可以查阅:https://xlsxwriter.readthedocs.io/

以上这篇windows下安装Python的XlsxWriter模块方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python 实现淘宝秒杀的示例代码

新手学习Python,之前在网上看见一位朋友写的40行Python代码搞定京东秒杀,想在淘宝上帮女朋友抢玩偶,所以就照猫画虎的写了下淘宝的秒杀脚本,经自己实验可行。直接上代码: #-...

python and or用法详解

python and or用法详解

and 和 or 是python的两个逻辑运算符,可以使用and , or来进行多个条件内容的判断。下面通过代码简单说明下and or的用法: 1. or:当有一个条件为真时,该条件即为...

浅析python3字符串格式化format()函数的简单用法

 format()函数 """ 测试 format()函数 """ def testFormat(): # format()函数中有几个元素,前面格式化的字符串中就要有...

python下载文件记录黑名单的实现代码

具体代码如下所示: #!/usr/bin/python # -*- coding: GBK -*- # -*- coding: UTF-8 -*- from ftplib impo...

python3+PyQt5+Qt Designer实现扩展对话框

python3+PyQt5+Qt Designer实现扩展对话框

本文是对《Python Qt GUI快速编程》的第9章的扩展对话框例子Find and replace用Python3+PyQt5+Qt Designer进行改写。 第一部分无借用Qt...