Unable to install NLTK on MacOS High Sierra - python

This text is to add some extra text to escape the error and has nothing to do with the question. Please excuse!
Install:
sudo pip install -U nltk
I am getting the following error while installing NLTK on my laptop.
Please help!
Error
Collecting nltk
Downloading nltk-3.2.5.tar.gz (1.2MB)
100% |████████████████████████████████| 1.2MB 201kB/s
Collecting six (from nltk)
Downloading six-1.11.0-py2.py3-none-any.whl
Installing collected packages: six, nltk
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
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 778, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-0HVpKZ uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
I tried this command but didn't work
python -m pip install --upgrade pip setuptools wheel (Even this does not install)

It's best practice to create a virtual environment before installing packages, see http://docs.python-guide.org/en/latest/dev/virtualenvs/
Nevertheless, TL;DR:
pip install --user --upgrade nltk

Related

Upgrade pip3 accesses incorrect directory macOS [duplicate]

I need to upgrade pip on my Ubuntu system but I am getting error:
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
File "/home/shivams334/.local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/shivams334/.local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/home/shivams334/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 742, in install
**kwargs
File "/home/shivams334/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/home/shivams334/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "/home/shivams334/.local/lib/python2.7/site-packages/pip/wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/shivams334/.local/lib/python2.7/site-packages/pip/wheel.py", line 317, in clobber
ensure_dir(destdir)
File "/home/shivams334/.local/lib/python2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pip-9.0.1.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.
Maybe I should go with 'chown' but don't know how to use it. Please help.
Since you want to upgrade your system-wide Python, you need to run this command with administrator privilege:
sudo pip install -U pip
But, I recommend you not changing/polluting your system-wide Python. Instead use a virtualenv:
virtualenv myapp
source myapp/bin/activate
pip install -U pip # <- only if virtualenv is not up to date

Numpy Upgrade fails

sudo pip install numpy --upgrade  PsYcH0
The directory '/Users/karanj/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/karanj/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting numpy
Downloading numpy-1.13.1-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.6MB)
100% |████████████████████████████████| 4.6MB 281kB/s
Installing collected packages: numpy
Found existing installation: numpy 1.8.0rc1
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling numpy-1.8.0rc1:
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 778, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-tfPgJ6-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
Can't get to upgrade numpy because of Errno 1 please help how do I upgrade Numpy.
Tried Unistalling also, but it can't uninstall numpy throws the same error.
Try with python -m pip install SomePackage. -m means that it will install the latest version of the package. Also have a look over here for a nice explanation.

Error upgrading pip on Mac: IOError: [Errno 1] Operation not permitted: '/bin/pip'

I'm on OS X El Capitan 10.11.6 with homebrew installed python 2.7. I've removed and re-installed python via homebrew with no joy. pip can neither install site-packages or update itself.
Trying to upgrade pip and receive the following error:
$ pip install --upgrade pip
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Rolling back uninstall of pip
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 317, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 742, in install
**kwargs
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 463, in move_wheel_files
generated.extend(maker.make(spec))
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 372, in make
self._make_script(entry, filenames, options=options)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 276, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 250, in _write_script
self._fileop.write_binary_file(outname, script_bytes)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/util.py", line 405, in write_binary_file
with open(path, 'wb') as f:
IOError: [Errno 1] Operation not permitted: '/bin/pip'
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.
Found the answer here: Python: pip tries to install to /bin directory
I had a .pydistutils.cfg file in my home directory that was a workaround for something else (I forget what) and once removed it solved all my pip problems.

Install Mercurial 3.4.2 for mac

I am trying to install Mercurial 3.4.2 for mac with code:
pip install mercurial==3.4.2
But have an error:
Collecting mercurial==3.4.2
Installing collected packages: mercurial
Found existing installation: mercurial 3.9.1
DEPRECATION: Uninstalling a distutils installed project (mercurial) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling mercurial-3.9.1:
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 317, 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 115, 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/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 303, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/mercurial-3.9.1-py2.7.egg-info'
Can anyone help me with that thing?
This solution as helpful for me:
sudo chown -R $(whoami) $(brew --prefix)/*

Python Version Dependency Issue - pip uninstall

I'm getting an error when I'm trying to uninstall matplotlib or upgrade pip. For example:
%pip install --upgrade pip
After it downloads pip and installs it, it tries to uninstall the old version. I get the error:
You are using pip version 7.1.0, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip
Downloading pip-8.0.2-py2.py3-none-any.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 506kB/s
Installing collected packages: pip
Found existing installation: pip 7.1.0
Uninstalling pip-7.1.0:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 640, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 726, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_uninstall.py", line 125, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py", line 314, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 300, in move
rmtree(src)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree
os.remove(fullname)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/EGG-INFO/dependency_links.txt'
Any guidance would be appreciated.
Try this : sudo pip install --upgrade pip
Why sudo ? sudo is always run with superuser privileges (as root). Thus sudo has the ability to do some privileged tasks like calling system functions only allowed for root. Since you are getting a permission denied error, running the same command using sudo will not ask for permission since you are root

Categories