如何在没有sudo或wget或brew或easy_install的情况下安装pip?

时间:2016-07-18 16:17:20

标签: python macos installation pip sudo

我正在尝试下载pip,但我没有sudo访问权限。我收到这个错误:

Exception:
Traceback (most recent call last):
  File "/var/folders/h3/mg0jxd6x7v9gmrg89kcwxbfcpm025t/T/tmp0PONb0/pip.zip/pip/basecommand.py", line 215, in main
status = self.run(options, args)
  File "/var/folders/h3/mg0jxd6x7v9gmrg89kcwxbfcpm025t/T/tmp0PONb0/pip.zip/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
  File "/var/folders/h3/mg0jxd6x7v9gmrg89kcwxbfcpm025t/T/tmp0PONb0/pip.zip/pip/req/req_set.py", line 742, in install
**kwargs
  File "/var/folders/h3/mg0jxd6x7v9gmrg89kcwxbfcpm025t/T/tmp0PONb0/pip.zip/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/var/folders/h3/mg0jxd6x7v9gmrg89kcwxbfcpm025t/T/tmp0PONb0/pip.zip/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
  File "/var/folders/h3/mg0jxd6x7v9gmrg89kcwxbfcpm025t/T/tmp0PONb0/pip.zip/pip/wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
  File "/var/folders/h3/mg0jxd6x7v9gmrg89kcwxbfcpm025t/T/tmp0PONb0/pip.zip/pip/wheel.py", line 317, in clobber
ensure_dir(destdir)
  File "/var/folders/h3/mg0jxd6x7v9gmrg89kcwxbfcpm025t/T/tmp0PONb0/pip.zip/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/pip'

我试图通过许多其他解决方案,但他们每个都需要sudo,wget,brew和/或easy_install等。有人可以提供我应该采取的步骤,没有这些下载点?

谢谢!

2 个答案:

答案 0 :(得分:0)

使用virtualenv

创建并激活virtualenv并在virualenv中安装您的软件包。您不需要sudo访问。

答案 1 :(得分:0)

https://pip.pypa.io/en/stable/installing/

您可以下载.py文件并运行它来安装pip。