1. 安装Python27
1.1 下载 python27 安装包
1.2 安装
1.3 配置环境变量
1.4 验证
- 打开
cmd 命令提示符,输入Python2 ,可以正确进入 Python 命令行操作界面,表示安装成功。
2. pip 安装模块错误
C:\Python27\Scripts>pip install numpy==1.9.3
Collecting numpy==1.9.3
Cache entry deserialization failed, entry ignored
Exception:
Traceback (most recent call last):
File "c:\python27\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "c:\python27\lib\site-packages\pip\commands\install.py", line 324, in run
requirement_set.prepare_files(finder)
File "c:\python27\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "c:\python27\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File "c:\python27\lib\site-packages\pip\download.py", line 821, in unpack_url
hashes=hashes
File "c:\python27\lib\site-packages\pip\download.py", line 659, in unpack_http_url
hashes)
File "c:\python27\lib\site-packages\pip\download.py", line 880, in _download_http_url
file_path = os.path.join(temp_dir, filename)
File "c:\python27\lib\ntpath.py", line 85, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 7: ordinal not in range(128)
You are using pip version 9.0.1, however version 22.0.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
- 错误原因:执行
c:\python27\lib\ntpath.py 文件时,result_path = result_path + p_path 语句,进行地址拼接是有中文字符。 - 解决方法:
import sys
reload(sys)
sys.setdefaultencoding("GBK")
|