Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip-9.0.1-py

本文介绍了一种常见的pip安装Django时遇到的权限错误,并提供了解决方案:通过在命令前添加sudo来获取足够的权限以完成安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Exception:

Traceback (most recent call last):

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main

    status = self.run(options, args)

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run

    prefix=options.prefix_path,

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install

    **kwargs

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install

    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files

    isolated=self.isolated,

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files

    clobber(source, lib_dir, True)

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber

    ensure_dir(destdir)

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir

    os.makedirs(path)

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs

    mkdir(name, mode)

OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/django'




解决办法

用  pip  安装  Django  的时候的错误


在命令前边加sudo  就好了


yangs@yangs:~$ virtualenv ~/venv/hrlnav --python=python3.6 Running virtualenv with interpreter /usr/bin/python3.6 Using base prefix &#39;/usr&#39; New python executable in /home/yangs/venv/hrlnav/bin/python3.6 Also creating executable in /home/yangs/venv/hrlnav/bin/python Installing setuptools, pkg_resources, pip, wheel... Complete output from command /home/yangs/venv/hrlnav/bin/python3.6 - setuptools pkg_resources pip wheel: Collecting setuptools Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ReadTimeoutError("HTTPSConnectionPool(host=&#39;pypi.python.org&#39;, port=443): Read timed out. (read timeout=15)",)&#39;: /simple/setuptools/ Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;ReadTimeoutError("HTTPSConnectionPool(host=&#39;files.pythonhosted.org&#39;, port=443): Read timed out. (read timeout=15)",)&#39;: /packages/b0/3a/88b210db68e56854d0bcf4b38e165e03be377e13907746f825790f3df5bf/setuptools-59.6.0-py3-none-any.whl Downloading https://files.pythonhosted.org/packages/b0/3a/88b210db68e56854d0bcf4b38e165e03be377e13907746f825790f3df5bf/setuptools-59.6.0-py3-none-any.whl (952kB) Exception: Traceback (most recent call last): File "/home/yangs/venv/hrlnav/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 302, in _error_catcher yield File "/home/yangs/venv/hrlnav/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 384, in read data = self._fp.read(amt) File "/home/yangs/venv/hrlnav/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 60, in read data = self.__fp.read(amt) File "/usr/lib/python3.6/http/client.py", line 467, in read n = self.readinto(b) File "/usr/lib/python3.6/http/client.py", line 511, in readinto n = self.fp.readinto(b) File "/usr/lib/python3.6/socket.py", line 586, in readinto return self._sock.recv_into(b) File "/usr/lib/python3.6/ssl.py", line 1012, in recv_into return self.read(nbytes, buffer) File "/usr/lib/python3.6/ssl.py", line 874, in read return self._sslobj.read(len, buffer) File "/usr/lib/python3.6/ssl.py", line 631, in read v = self._sslobj.read(len, buffer) socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 353, in run wb.build(autobuilding=True) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 821, in unpack_url hashes=hashes File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 659, in unpack_http_url hashes) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 902, in _download_http_url _download_url(resp, link, content_file, hashes) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 603, in _download_url hashes.check_against_chunks(downloaded_chunks) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/utils/hashes.py", line 46, in check_against_chunks for chunk in chunks: File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 571, in written_chunks for chunk in chunks: File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/utils/ui.py", line 139, in iter for x in it: File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 560, in resp_read decode_content=False): File "/home/yangs/venv/hrlnav/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 436, in stream data = self.read(amt=amt, decode_content=decode_content) File "/home/yangs/venv/hrlnav/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 401, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__ self.gen.throw(type, value, traceback) File "/home/yangs/venv/hrlnav/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 307, in _error_catcher raise ReadTimeoutError(self._pool, None, &#39;Read timed out.&#39;) urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=&#39;files.pythonhosted.org&#39;, port=443): Read timed out. ---------------------------------------- ...Installing setuptools, pkg_resources, pip, wheel...done. Traceback (most recent call last): File "/usr/lib/python3/dist-packages/virtualenv.py", line 2375, in <module> main() File "/usr/lib/python3/dist-packages/virtualenv.py", line 724, in main symlink=options.symlink) File "/usr/lib/python3/dist-packages/virtualenv.py", line 992, in create_environment download=download, File "/usr/lib/python3/dist-packages/virtualenv.py", line 922, in install_wheel call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT) File "/usr/lib/python3/dist-packages/virtualenv.py", line 817, in call_subprocess % (cmd_desc, proc.returncode)) OSError: Command /home/yangs/venv/hrlnav/bin/python3.6 - setuptools pkg_resources pip wheel failed with error code 2 这是什么错误
05-14
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值