1

I've been running Python 3 in Pycharm for a while now, and I tried to install a new module and it failed to install. Specifically it gave me a "Non-zero exit code (1)" and told me to attempt to install it from my terminal using PIP. I have since updated and reinstalled Pycharm and it still will not install new modules.

In the terminal, I attempted

pip --version

The response:

-bash: pip: command not found

I look up how to install PIP, and try:

sudo easy_install pip

This is what it said:

Searching for pip
Reading https://pypi.python.org/simple/pip/
Download error on https://pypi.python.org/simple/pip/: [SSL:
TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol   version 
(_ssl.c:590) -- Some packages may not be found!
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [SSL:     
TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)
-- Some packages may not be found!
No local packages or download links found for pip
error: Could not find suitable distribution for     
Requirement.parse('pip')

So I go back to google and do a little more searching and find to try it without the sudo, so

easy_install pip

Then it gives me this:

error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-       
easy-install-2117.pth'

The installation directory you specified (via --install-dir, --prefix,  
or the distutils default setting) was:

/Library/Python/2.7/site-packages/

Perhaps your account does not have write access to this directory?  If
the installation directory is a system-owned directory, you may need to
sign in as the administrator or "root" account.  If you do not have 
administrative access to this machine, you may wish to choose a   
different installation directory, preferably one that is listed in your
PYTHONPATH environment variable.

For information on other options, you may wish to consult the
documentation at:

https://pythonhosted.org/setuptools/easy_install.html

Please make the appropriate changes for your system and try again.

so then I find this earlier question: Why is Python easy_install not working on my Mac?

I try:

sudo rm -f /usr/bin/easy_install*

and it gives me

rm: /usr/bin/easy_install: Operation not permitted
rm: /usr/bin/easy_install-2.6: Operation not permitted
rm: /usr/bin/easy_install-2.7: Operation not permitted

So then I find this old question: Installing pip on macOS does not work (anymore), which has 2 answers saying to just install homebrew. So I try that:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.comnn
/Homebrew/install/master/install)"

Homebrew installs, and I think I'm ready to go.

pip --version

-bash: pip: command not found

EDIT: I tried

echo $PATH

I had forgotten that I originally used Python through Anaconda and removed it, and that's probably what started this. Is there any way to fix this?

Steve D
  • 11
  • 1
  • 3
  • You need to start a new shell after installing Homebrew. However, I find PyEnv is easier to work with https://github.com/pyenv/pyenv – OneCricketeer May 02 '18 at 02:31
  • I have begun a new shell. it still does not find PIP – Steve D May 02 '18 at 02:55
  • `sudo easy_install pip` will try to install pip for your Apple builtin Python 2.7, not for… whichever Python 3 you're using. – abarnert May 02 '18 at 03:29
  • 1
    The answer about `sudo rm /usr/bin/easy_install *`was never a very good idea for macOS (those files are owned by the OS), and even less so now that `distribute` no longer exists, so… probably a good thing that it failed. – abarnert May 02 '18 at 03:30
  • Finally, installing Homebrew doesn't install Homebrew' Python—that's a second step, `brew install python`. But you probably don't want to do that—it will install yet another Python 3, not fix your existing one, and you'll have to start all over. – abarnert May 02 '18 at 03:36
  • Anyway, "I originally used Python through Anaconda and removed it." Yes, if you uninstall Anaconda (and its included Python), you no longer have that Python, or the packages you installed for it, or the `pip` that goes with it. Are you sure Pycharm is still running Python 3 code at all, and not just Python 2.7 (with Apple's python)? If so, you must have another Python 3 that was fighting with the Anaconda one. The ideal thing to do is to get everything cleaned up, deleting everything but the Apple pre-installed 2.7, then install exactly one 3.6 of your choice. – abarnert May 02 '18 at 03:38
  • I found my path, and this is it: /Users/myname/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin so it looks like my computer is defaulting to a path that isn't really there anymore? If I try "which python" it returns "/usr/bin/python" – Steve D May 02 '18 at 04:04
  • Possible duplicate of [Not able to install python packages \[SSL: TLSV1\_ALERT\_PROTOCOL\_VERSION\]](https://stackoverflow.com/questions/49768770/not-able-to-install-python-packages-ssl-tlsv1-alert-protocol-version) – hoefling May 02 '18 at 08:02
  • Possible duplicate of [Installing pip on macOS Sierra](https://stackoverflow.com/questions/41233594/installing-pip-on-macos-sierra) – Tom Zych Aug 20 '18 at 04:45

2 Answers2

4

For Mac OS Sierra, cannot install pip via easy_install

So install pip using curl as follows,

curl https://bootstrap.pypa.io/get-pip.py | sudo python
Mohammed Safeer
  • 20,751
  • 8
  • 75
  • 78
0

Pip is already installed with Python , so if it is not working then you should try to reinstall python (the latest version) and then try checking if you have pip installed .If that doesn't work - then you should type this into the terminal - curl https://bootstrap.pypa.io/get-pip.py | sudo python . HTH (: . I tried re installing python and that worked for me ( I am also on a mac)