1

Please can you help me install pip? I previously had pip but somehow I broke it and I tried uninstalling python and reinstalling it but I still cannot get pip back...

sudo python get-pip.py

The directory '/Users/Name/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/Name/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. Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages

sudo -H python get-pip.py

Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages

I also tried this:

sudo easy_install pip

Traceback (most recent call last): File "/usr/bin/easy_install-2.7", line 7, in from pkg_resources import load_entry_point File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2927, in @_call_aside File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2913, in _call_aside f(*args, **kwargs) File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2940, in _initialize_master_working_set working_set = WorkingSet._build_master() File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 637, in _build_master return cls._build_from_requirements(requires) File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 650, in _build_from_requirements dists = ws.resolve(reqs, Environment()) File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 829, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'setuptools==1.1.6' distribution was not found and is required by the application

Then I found that pip is installed with python, but for some reason pip is not working.

brew install python

Warning: python 2.7.13 is already installed

pip install regex

zsh: command not found: pip

pip install --upgrade pip

zsh: command not found: pip

When I go here > cd /usr/local/lib/python2.7/site-packages && ls I find distribute-0.6.14-py2.7.egg and pip-9.0.1.dist-info

But when I go to /usr/local/bin I cannot find pip, only pip3:

I did try out some solutions from here but they are not working.

EDIT:

Following from the comment I tried

sudo pip install regex Password: sudo: pip: command not found ➜ ~ python -m pip install regex Collecting regex Downloading regex-2017.06.23.tar.gz (607kB) 100% |████████████████████████████████| 614kB 694kB/s Building wheels for collected packages: regex Running setup.py bdist_wheel for regex ... done Stored in directory: /Users/Manal/Library/Caches/pip/wheels/aa/48/61/f321b8a521167213da5de2a65e76530e362e58e328b1d74ab3 Successfully built regex Installing collected packages: regex Successfully installed regex-2017.6.23

I'm not sure why it worked? How can I use pip normally?

EDIT:

Something broke I think..

➜ ~ pip install regex zsh: command not found: pip ➜ ~ ➜ ~ python -m pip install regex Requirement already satisfied: regex in /usr/local/lib/python2.7/site-packages ➜ ~ which pip pip not found

I dont know why which pip isnt returning anything?

EDIT:

Tried installing setup tools

➜ ~ sudo brew install python-setuptools Password: Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system. ➜ ~ ➜ ~ brew install python-setuptools Error: No available formula with the name "python-setuptools" ==> Searching for a previously deleted formula... Warning: homebrew/core is shallow clone. To get complete history run: git -C "$(brew --repo homebrew/core)" fetch --unshallow Error: No previously deleted formula found. ==> Searching for similarly named formulae... Error: No similarly named formulae found. ==> Searching taps... Error: No formulae found in taps. ➜ ~ ➜ ~ sudo apt-get install python-setuptools sudo: apt-get: command not found ➜ ~ ➜ ~ easy_install -U setuptools Traceback (most recent call last): File "/usr/bin/easy_install-2.7", line 7, in from pkg_resources import load_entry_point File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2927, in @_call_aside File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2913, in _call_aside f(*args, **kwargs) File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2940, in _initialize_master_working_set working_set = WorkingSet._build_master() File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 637, in _build_master return cls._build_from_requirements(requires) File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 650, in _build_from_requirements dists = ws.resolve(reqs, Environment()) File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 829, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'setuptools==1.1.6' distribution was not found and is required by the application

MTA
  • 739
  • 2
  • 9
  • 29
  • do `sudo pip install regex` to install or try `python -m pip install regex` – Stack Jul 03 '17 at 15:43
  • @Stack Please see the Edit. python -m pip install regex seems to work, how can I use pip normally? – MTA Jul 03 '17 at 15:57
  • `python -m pip install regex` worked because the `-m` is for `module` and `pip` is also a module, its an alternative way. – Stack Jul 03 '17 at 16:00
  • i think `pip` is not working normally because it is not in path, just add the directory where `pip` is present to the path. – Stack Jul 03 '17 at 16:01
  • you can find the directory where `pip` is installed by this command `which pip` and add it to the path variable by : `export PATH=$PATH:/path/to/pip_dir` – Stack Jul 03 '17 at 16:04
  • which pip returns, //anaconda/bin/pip is that a little messed up? because i'm using homebrew – MTA Jul 03 '17 at 16:07
  • doesnt matter, try adding that to `PATH` – Stack Jul 03 '17 at 16:11
  • Ok I added the path but there is still an issue when i try to install other packages – MTA Jul 03 '17 at 16:22
  • Or maybe this isnt an issue with pip? Maybe i made a mistake with installing tensorflow – MTA Jul 03 '17 at 16:23
  • @Stack I dont know what happened but which pip doesnt return anything now.. please see my edit above – MTA Jul 03 '17 at 16:40
  • open the terminal in your root directory and type `which pip` – Stack Jul 03 '17 at 16:44
  • pip not found, it only works when I do python -m pip install regex – MTA Jul 03 '17 at 16:47
  • When i check this directory there is pip: /usr/local/lib/python2.7/site-packages/pip.. but this directory is not returned when I type which pip. Which python returns /usr/local/bin/python – MTA Jul 03 '17 at 16:49
  • when you do `which pip` change your directory to `usr/local/` and try – Stack Jul 03 '17 at 16:50
  • ➜ ~ cd /usr/local ➜ local which pip pip not found – MTA Jul 03 '17 at 16:52
  • `sudo apt-get install python-setuptools` , then do `sudo easy_install pip` – Stack Jul 03 '17 at 16:52
  • I'm using a mac. shall I just use brew instead of apt-get? – MTA Jul 03 '17 at 16:53
  • yes try that, if it doest work try apt-get – Stack Jul 03 '17 at 16:54
  • @Stack sorry it doesnt seem to be working, I dont know how I got into this mess :(. Please see edit above. – MTA Jul 03 '17 at 17:00
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/148240/discussion-between-stack-and-reguser). – Stack Jul 03 '17 at 17:02
  • https://crossbar.io/docs/Installation-on-Mac-OS-X/ – Alexander Nov 12 '18 at 16:06

0 Answers0