I've been puzzled for a while. I can't install/upgrade any package for my python35 now. I have python27 and python35(via anaconda) on mac. Whenever I want to install a python package via pip, the one paired with python2 was invoked.
Go to anaconda folder(where my python35 installed): ls -al | grep pip I got the result:
-rwxrwxr-x 1 xx staff 113 Jul 26 2016 conda-pipbuild
-rwxr-xr-x 1 xx staff 230 Dec 17 21:40 pip
-rwxr-xr-x 1 xx staff 230 Dec 17 21:40 pip3
-rwxr-xr-x 1 xx staff 230 Dec 17 21:40 pip3.5
In my .bashrc file, I defined:
alias python2=/usr/bin/python2.7
alias python=~/anaconda/bin/python3.5
When I type python2:
$ python2
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
When I type python:
$ python
Python 3.5.2 |Anaconda custom (x86_64)| (default, Jul 2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
When type: pip -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
When type pip3 -V
-bash: pip3: command not found
which pip
/usr/local/bin/pip
To reinstall pip3, I downloaded get-pip.py from https://pip.pypa.io/en/latest/installing/ From the doc it says, it will install the correct pip according to the version of Python runs the script. Therefore, I ran
python get-pip.py
Requirement already up-to-date: pip in /Users/xxx/anaconda/lib/python3.5/site-packages
Below shows When I try to install a package with pip:
pip install tushare --upgrade
Collecting tushare
Using cached tushare-1.0.7-py2-none-any.whl
Requirement already up-to-date: lxml>=3.8.0 in /Library/Python/2.7/site-packages (from tushare)
pip3.5or something similar. If you want to access it when typingpip3, you should set an alias for it. Better yet, package your code into virtual environments and when you're inside a venv you will be able to access pip3 withpip~/binif you have a bin directory in your homedir. It all depends on your PATH