首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装djangorestframework时获取错误-权限被拒绝:'/usr/lib/python2.7/site-packages/djangorestframework-3.6.3.dist-info‘

安装djangorestframework时获取错误-权限被拒绝:'/usr/lib/python2.7/site-packages/djangorestframework-3.6.3.dist-info‘
EN

Stack Overflow用户
提问于 2017-05-19 12:42:52
回答 1查看 482关注 0票数 0

我想在fedora-25中安装Django rest框架,但是当我运行这个命令时:

代码语言:javascript
复制
pip install djangorestframework

我收到了以下错误:

代码语言:javascript
复制
Collecting djangorestframework
Using cached djangorestframework-3.6.3-py2.py3-none-any.whl
Installing collected packages: djangorestframework
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 326, in run
strip_file_prefix=options.strip_file_prefix,
File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 742, in install
**kwargs
File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 834, in install
strip_file_prefix=strip_file_prefix
File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 1037, in move_wheel_files
strip_file_prefix=strip_file_prefix,
File "/usr/lib/python2.7/site-packages/pip/wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python2.7/site-packages/pip/wheel.py", line 317, in clobber
ensure_dir(destdir)
File "/usr/lib/python2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib64/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/djangorestframework-3.6.3.dist-info'
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

当我使用sudo尝试上面的命令时,会得到以下错误

代码语言:javascript
复制
Collecting djangorestframework
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0011a7bf10>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/djangorestframework/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0013a4fe50>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/djangorestframework/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0011788050>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/djangorestframework/

当我试图升级pip的时候

代码语言:javascript
复制
pip install --upgrade pip

同样,当我使用sudo运行它时,会得到以下错误

代码语言:javascript
复制
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7eff30658ed0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7eff3262cf10>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pip/

我该怎么办?还有其他方法来安装djangorestframework吗?

请帮我把这个:

EN

回答 1

Stack Overflow用户

发布于 2017-05-19 13:02:50

尝试使用虚拟环境。

代码语言:javascript
复制
sudo apt-get install python-virtualenv
virtualenv myvenvname // create ur env
source myvenvname/bin/activate // activate it if it isnt already activated

在您的虚拟环境中安装所有的软件包,以避免与其他包发生冲突,这可能解决您的问题。

另一件事是,正如我所看到的,您正在尝试使用python2.7安装它。这是你想要的版本吗?如果您想使用python 3安装它,请执行以下操作:

代码语言:javascript
复制
pip3 install djangorestframework
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44070459

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档