Mac builds a python development environment

Guide:
        1. First install brew
         ruby ​​-e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

        2. Install wget with brew

         brew install wget

       3. Download pip.py with wget 

       wget https://bootstrap.pypa.io/get-pip.py

      python install get-pip.py

 

       4. When developing with python that comes with mac, it will always prompt that some modules are missing, so it is best to reinstall python

       5. Download the pychar development tool

       6. just do it


[align=baseline; zoom: 1; line-height: 22.4px ;]
1. Install python

1.homebrew

1

 

 




The solution of brew install python


is relatively simple. If there is an error, you can try adding sudo to the front. The installed python may not be the latest version.
2. Download and install from the official website. You can download and install
it from https://www.python.org/download The latest version of python, the installation is relatively mindless, press all the way to OK, the disadvantage is that the upgrade and uninstallation have to be maintained by yourself.


1



which python


to check the installation location. After the installation is complete, type python in the terminal to verify whether the installation is successful.
2 . Install pip

1. Let's get the pip installation script first:

1



wget https://bootstrap.pypa.io/get-pip.py


If you don't have wget installed, you can go here and copy all the content, create a new get-pip.py file, Copy the content in and it is OK.
2. Install pip

1



sudo python get-pip.py


execute the script just obtained with python, where sudo can be used, if you encounter a similar error, you must add sudo:

1
2
3
4
5
6
7
8
9



Exception:

Traceback (most recent call last):

...

OSError: [Errno 13] Permission denied: 'XXX/pip-0.7.2-py2.7.egg/EGG-INFO/dependency_links.txt'

Storing debug log for failure in /Users/bilt/.pip/pip.log


install After success, you can type pip in the terminal to detect, if not, restart the terminal and try.
3. Modify the pip source

first enter the HOME path:

1



cd ~


create .pip directory:

1



mkdir .pip


create pip.conf file:

1



touch pip. conf


, you can open the pip.conf file with your favorite editor. I am using the source of v2ex, so add:

1
2



[global]
index-url = http://pypi.v2ex.com/simple


You can put The value of index-url is set to the address of its actual source.

3. Other modules are installed
1. Pillow/PIL
wants to use python to process pictures, naturally the PIL module is indispensable. Since PIL has not been updated for a long time, with the Pillow module, it depends on For PIL, the new version of pip will come with Pillow after installation, but it seems that there is no zlib module, so an error will be reported:

File "/Library/Python/2.7/site-packages/PIL/Image.py", line 1105, in paste
    im.load()

  File "/Library/Python/2.7/site-packages/PIL/ImageFile.py", line 190, in load

    d = Image._getdecoder(self.mode, d, a, self.decoderconfig)

  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 389, in _getdecoder

    raise IOError("decoder %s not available" % decoder_name)

IOError: decoder zip not available


因此我们需要手动重新安装:

sudo pip install -U Pillow

 reference:http://blog.csdn.net/fancylovejava/article/details/39140373

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326346381&siteId=291194637