Friday, June 8, 2018

Unable to download mongo-connector using pip

Leave a Comment

I am trying to install mongo-connector on Amazon-EC2 instance using the following command:

 pip install mongo-connector 

But following error flashes up everytime:

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' 

I thought this might be some issue with root permissions, so I tried :

sudo pip install mongo-connector 

But this says ,

sudo: pip: command not found 

I am using pip 8.1.2, Python 2.7.12.

Any help would be appreciated!

5 Answers

Answers 1

I solved this by using the following command:

sudo `which pip`install mongo-connector 

Answers 2

You shouldn't be using sudo to install packages with pip. While it works, it's modifying files that should be managed by your OS package manager which isn't desirable -- see also https://stackoverflow.com/a/21056000/1931274.

If you pass --user to that command, you'll be able to install without permission issues:

pip install --user mongo-connector 

Moreover, newer versions of pip (installable via pip install --user pip or using get-pip.py) print a better, more helpful message when such errors occur.

Answers 3

For windows download required precompiled python packages from https://www.lfd.uci.edu/~gohlke/pythonlibs/ and pip install <point to the downloaded file>.

Answers 4

One more way to solve this is:

sudo bash  

now you are in a bash with root privileges so now you can execute

pip install mongo-connector 

without any permission issues

Answers 5

As mentioned above the following command will work for sure.

sudo `which pip`install mongo-connector 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment