为 python 2.7.13 安装请求模块 [英] installing requests module for python 2.7.13

查看:39
本文介绍了为 python 2.7.13 安装请求模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[Python-2.7]我试图使用以下命令在 python 中安装请求模块

<块引用><块引用><块引用>

导入点pip.main(['安装', '请求'])我遇到了这些问题:

异常:回溯(最近一次调用最后一次):文件/usr/local/lib/python2.7/dist-packages/pip/basecommand.py",第 215 行,在主目录中status = self.run(options, args)运行中的文件/usr/local/lib/python2.7/dist-packages/pip/commands/install.py",第 342 行前缀=options.prefix_path,文件/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py",第784行,安装**夸格安装文件/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py",第851行self.move_wheel_files(self.source_dir, root=root, prefix=prefix)文件/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py",第 1064 行,在 move_wheel_files 中孤立 = self.isolated,文件/usr/local/lib/python2.7/dist-packages/pip/wheel.py",第 345 行,在 move_wheel_files 中破坏者(源代码,lib_dir,真)文件/usr/local/lib/python2.7/dist-packages/pip/wheel.py",第316行,在clobber确保目录(目标目录)文件/usr/local/lib/python2.7/dist-packages/pip/utils/__init__.py",第83行,在ensure_diros.makedirs(路径)文件/usr/lib/python2.7/os.py",第 157 行,在 makedirs 中mkdir(名称,模式)OSError: [Errno 13] 权限被拒绝: '/usr/local/lib/python2.7/dist-packages/certifi-2017.7.27.1.dist-info'2

谁能帮帮我?对此,我真的非常感激.

解决方案

您需要以超级用户身份运行此程序或在本地安装此程序包(使用 --user 标志)

导入pip;pip.main(['install', '--user', 'requests'])

这里的问题是pip无法将文件写入/usr/local/lib/python2.7/dist-packages/,因为它没有足够的权限.

[Python-2.7] I was trying to install the requests module in python using the following commands

import pip pip.main(['install', 'requests']) and I run in to these issues:

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/usr/local/lib/python2.7/dist-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/certifi-2017.7.27.1.dist-info'
2

Can anyone help me? I really appreciate it.

解决方案

You need to either run this program as superuser or install this package locally (with the --user flag)

import pip; 
pip.main(['install', '--user', 'requests'])

The problem here is that pip cannot write files to /usr/local/lib/python2.7/dist-packages/ because it doesn't have enough privileges.

这篇关于为 python 2.7.13 安装请求模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆