window操作Python27

1. 安装Python27

1.1 下载 python27 安装包

1.2 安装

  • 双击安装包,进入安装页面,之后一直傻瓜式安装。

1.3 配置环境变量

  • PATH 添加 Python 的安装路径

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 语句,进行地址拼接是有中文字符。
  • 解决方法:
# 打开c:\python27\lib\ntpath.py,添加下面语句。
import sys
reload(sys)
sys.setdefaultencoding("GBK")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值