无法使用pip下载mongo-connector

时间:2016-09-13 05:43:10

标签: linux mongodb amazon-ec2 pip

我正在尝试使用以下命令在mongo-connector上安装Amazon-EC2 instance

 pip install mongo-connector

但每次都会出现以下错误:

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in                                                                                         main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 31                                                                                        7, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 736, in                                                                                         install
    requirement.uninstall(auto_confirm=True)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 742                                                                                        , in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_uninstall.py", line 1                                                                                        15, in remove
    renames(path, new_path)
  File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 267,                                                                                         in renames
    shutil.move(old, new)
  File "/usr/lib64/python2.7/shutil.py", line 300, in move
    rmtree(src)
  File "/usr/lib64/python2.7/shutil.py", line 252, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "/usr/lib64/python2.7/shutil.py", line 250, in rmtree
    os.remove(fullname)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/dist-packages/request                                                                                        s/sessions.pyo'

我认为这可能是root权限的一些问题,所以我尝试了:

sudo pip install mongo-connector

但是这说,

sudo: pip: command not found

我正在使用pip 8.1.2Python 2.7.12

任何帮助将不胜感激!

4 个答案:

答案 0 :(得分:5)

我使用以下命令解决了这个问题:

sudo `which pip`install mongo-connector

答案 1 :(得分:1)

您不应该使用sudo来安装带有pip的软件包。虽然它有效,但它修改了应该由您的操作系统包管理器管理的文件,这是不可取的 - 另请参阅https://stackoverflow.com/a/21056000/1931274

如果您将--user传递给该命令,则可以在没有权限问题的情况下安装:

pip install --user mongo-connector

此外,较新版本的pip(可通过pip install --user pip安装或使用get-pip.py)在发生此类错误时打印出更好,更有用的消息。

答案 2 :(得分:0)

对于Windows,从https://www.lfd.uci.edu/~gohlke/pythonlibs/pip install <point to the downloaded file>下载所需的预编译python包。

答案 3 :(得分:0)

解决此问题的另一种方法是:

sudo bash 

现在你处于具有root权限的bash中,所以现在你可以执行

pip install mongo-connector

没有任何权限问题