简体   繁体   中英

Using pip for python 2.7, After having installed Anaconda with 3.6 (mac)

I just got a new mac, and immediately installed Anaconda with python 3.6. However, I now need to go back and use python 2.7 for a project. This project also requires a few packages which could normally be installed with pip. However, after I installed anaconda, pip defaults to working with python3.

How can I access (or install, as it does not appear that the mac comes preloaded with pip for python 2.7) the pip for the python 2.7 that comes preloaded on the mac?

**I have tried pip2, pip2.7 as some other posts have suggested.

*** When I try to install pip (sudo easy_install pip) it defaults to looking at the Anaconda distribution)

The great thing about anaconda is the easy way of managing multiple different environments. And that is what you are looking for.

All you have to do is creat an environment with python version 2.7. Right now you only have the default(root) environment.

A really good video on how to actually use anaconda is here (11mins and only the last 5-6 mins are what you're actually looking for)

Basically you type the following in your terminal:

  • to see all the environments you have right now: conda env list

  • to create a new env called py27env: conda create --name py27env python=2.7 (+ other modules you want...)

  • to activate the environment: source activate py27env

  • to see which python version you are using: which python

  • to exit an environment: source deactivate

I have been struggling for this problem for weeks but finally fixed it what you have to do is move the pip package to and updated 'sites-packages' folder. for me, I downloaded pygame and the pip correctly install but wasn't working on my python3 editor. I went into my finder and went to MacintoshHD/frameworks/python/versions. Then I opened up a new tab in finder at the same location. Then for both the 3.8 and the 2.7 versions go to /lib/python/site-packages. then you will see the pip packages in the 2.7 'site-packages folder' you want to move those files to the 3.8 "site-packages" folder. It worked for me! hope it works for you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM