Python的安装

1.下载Python程序

首先访问http://www.python.org/download/去下载最新的python版本。

根据需要下载 python2 或者python3, 同时注意自己的操作系统版本是64位还是32位,选择符合自己的

这里介绍python2 的安装

2.安装下载包,一路next。

3.配置环境变量

右键计算机-->属性-->高级系统设置-->环境变量-->

在系统变量里面找到   Path, 然后将python 安装路径加入进去, 注意里面的分号是英文格式的  ‘;’



打开cmd 终端参照下面,如果能显示python 版本, python 就可以工作了

C:\>python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 'hello world'
>>> print a
hello world
>>>


4. 其他配置

虽然至此python 能够工作了,但是还有一些其他的内容需要配置

我们使用python 的时候,难免要使用到一些第三方库,或者一些架构,因此需要先把工具准备好


4.1 pip 工具

首先 同样的配置环境变量

将python 目录下的Script 也加到环境变量中去

C:\Python27\Scripts

然后在命令行下执行pip

但是很遗憾, 系统提示如下:

C:\Python27>pip
'pip' 不是内部或外部命令,也不是可运行的程序
或批处理文件。


为什么呢, 因为刚才的终端没有关闭, 需要我们重新打开一下, 然后我们尝试安装一下  bs4

C:\Python27\Scripts>pip install bs4
Collecting bs4
  Using cached bs4-0.0.1.tar.gz
Collecting beautifulsoup4 (from bs4)
  Using cached beautifulsoup4-4.5.3-py2-none-any.whl
Installing collected packages: beautifulsoup4, bs4
  Running setup.py install for bs4
Successfully installed beautifulsoup4-4.5.3 bs4-0.0.1
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

系统提示我们, pip 的版本太低了, 那我们升级一下pip 的版本

python -m pip install --upgrade pip

接着执行

pip install bs4
实验一下是否安装成功

C:\Python27\Scripts>python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import bs4
>>>
没有报错, 那就OK了


4.2 利用easy_install 安装 lxml


C:\Python27\Scripts>easy_install-2.7.exe lxml
Searching for lxml
Reading https://pypi.python.org/simple/lxml/
Best match: lxml 3.7.2
Downloading https://pypi.python.org/packages/66/45/f11fc376f784c6f2e77ffc7a9d02374ff3ceb07ede8c56f918939409577c/lxml-3.7.2.tar.gz#md5=8dcf8d6c692
Processing lxml-3.7.2.tar.gz
Writing c:\windows\temp\easy_install-iudefp\lxml-3.7.2\setup.cfg
Running lxml-3.7.2\setup.py -q bdist_egg --dist-dir c:\windows\temp\easy_install-iudefp\lxml-3.7.2\egg-dist-tmp-4pweyf
Building lxml version 3.7.2.
Building without Cython.
ERROR: 'xslt-config' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
error: Setup script exited with error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27


报错提示我们需要安装 Microsoft Visual C++ 9.0

点击这里下载

安装下载好的 VCForPython27.msi 一路next 就好


同时也需要安装 pywin32 

下载地址 

安装下载好的pywin32一路next 就好


这些都安装好了之后,继续通过命令行安装lxml,但是可能会因为网速的原因,这种方式依然安装的很慢,那么我们只能通过直接下载安装包的方式来安装

lxml下载地址:点击   根据操作系统选择不同的版本(32位或者64位的)

安装下载好的lxml程序一路next 就好


安装scrapy

pip install scrapy


现在可能遇到这样的错误


ImportError DLL load failed: %1 不是有效的 Win32 应用程序


是由于安装的32位的 MySQL-Python-1.2.3.win32-py2.exe,,只要改成64位版本的就可以了或者是你本身是64位的操作系统然后安装了32位的python


如果是 MySQL-Python安装错误,直接更改它的版本就行,如果是python 版本错误,那么需要重新安装上面的步骤

MySQL-Python可以使用如下链接下载:

32位:http://download.csdn.net/detail/seven_zhao/6607621

64位:http://download.csdn,net/detail/seven_zhao/6607625

也可以在如下地址下载:

http://www.codegood.com/downloads












评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值