Mac OS Not pre installed in Unix/Linux Common command line package management tools in ,Mac OS Medium App Store And its own software upgrade function can download and update many better applications , But most of these applications meet the needs of ordinary consumers , For developers , Command line package management tool is the king .

Mac OS There are three main package management tools in :MacPorts,Homebrew,Fink.

Here is a brief introduction to the differences between the three :

1. MacPorts: because Mac OS Derived from BSD, So it will BSD Medium Port Migration to OS Become MacPorts It's not surprising .MacPorts Will be independent of OS Build a warehouse tree ,OS The package execution directory of is /usr/local, and MacPorts The package execution directory of is /opt/local.MacPorts Try not to affect the existing procedures of the system , Naturally, it is necessary to reuse the existing programs of the system as little as possible .MacPorts The process of installing the package is to download all the source files of the program and its dependent packages , And then it's done locally Build Generate the final executable file . The advantage of this is that there is an independent ecological environment in the system , So as not to affect the ecological environment of the system itself , The disadvantage is that it wastes the ecological resources of the system itself .

2. Homebrew: stay Lion Then package management tools emerged , How to work and MacPorts similar , Download the source code and then download it locally Build. The difference is Homebrew Take with MacPorts The opposite attitude , The maximum utilization of system resources , So we can say Homebrew It is to modify the ecological environment of the existing system directly , All packages are also installed directly into the existing ecosystem , The advantage of this is to save system resources , But the disadvantage is that every operation is to modify the system directly , Rely heavily on and impact existing systems .

3. Fink: be based on Debian Of packaging tools, All it downloads are compiled binary executable files ( Or source code ), So there's no need to compile locally , Use as you go . The disadvantage is that all packages need Fink Precompile , The update speed can't keep up .

Use MacPorts and Homebrew All need to be pre installed XCode Command Line Tools, That means it needs to be pre installed XCode.( According to official documents ,Fink When installing a newer Kit , Because it's compiled ahead of time, there's no need to rely on XCode, But for some packages that are not binary , If you need to compile locally , Still need to rely on XCode. In other words , If you want to OS Compile source code in , Need to be XCode Provide support .)

On the subject : How to use MacPorts Install and use Python and pip?

Environmental Science :Mac OS X Mavericks

my Mavericks Bring their own Python Version has python25, python26, python27. I am using Python 2.7.6,Mavericks I'm carrying Python 2.7.5.

1. Check which is being used Python:

$ which python
/usr/bin/python $ whereis python
/usr/bin/python $ python

Python 2.7.5 (default, Aug 25 2013, 00:04:04)

[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>>

You can see that the current is Mavericks Self contained Python 2.7.5.

2. Use port search Find the target resource :

$ port search python | grep python27
dbus-python27 @0.84. (devel, python)
gnome-python27-extras @2.25. (gnome, python)
ice-python27 @3.4.2_3 (devel, python)
protobuf-python27 @2.4.1_1 (devel)
python27 @2.7. (lang)
python27-doc @2.7.2_1 (lang)
subversion-python27bindings @1.8. (devel, python) $ port search python | grep pip
Lightweight pipelining: using Python functions as pipeline jobs.
py-pip @1.5. (python, www)
py-pipedream @0.2.0_1 (python)
python module for easy communication over pipes
Plumbum (Latin for lead, which was used to create pipes back in the day) is a small yet feature-rich library for shell script-like programs in Python.
py24-pipedream @0.2.0_1 (python)
python module for easy communication over pipes
py25-pip @1.3.1_1 (python, www)
Lightweight pipelining: using Python functions as pipeline jobs.
py26-pip @1.5. (python, www)
Lightweight pipelining: using Python functions as pipeline jobs.
py27-pip @1.5. (python, www)
Plumbum (Latin for lead, which was used to create pipes back in the day) is a small yet feature-rich library for shell script-like programs in Python.
py31-pip @1.5. (python, www)
Lightweight pipelining: using Python functions as pipeline jobs.
py32-pip @1.5. (python, www)
Lightweight pipelining: using Python functions as pipeline jobs.
py33-pip @1.5. (python, www)
Plumbum (Latin for lead, which was used to create pipes back in the day) is a small yet feature-rich library for shell script-like programs in Python.
py34-pip @1.5. (python, www)
Plumbum (Latin for lead, which was used to create pipes back in the day) is a small yet feature-rich library for shell script-like programs in Python.

3. Choose what you need Python Version and pip Version to install . In fact, I'm skipping the installation here python27 @2.7.6 (lang), Direct installation py27-pip @1.5.4 (python, www), Because I said that before ,MacPorts The required tools and their dependent packages are automatically installed . So in installation py27-pip In the process of , It will be installed automatically python27.

$ sudo port install py27-pip
Password:
---> Computing dependencies for py27-pip
---> Cleaning py27-pip
---> Scanning binaries for linking errors: 100.0%
---> No broken files found.

That's it Python 2.7.6 and pip Installation . Be careful : Because I have installed before this article py27-pip, Therefore, the above examples are only for illustration , If you don't use MacPorts Installed py27-pip or python27, The output you see should be different . And if you're using it for the first time MacPorts Install the kit ,MacPorts There will be a first build The process of warehouse tree , Wait patiently .

4. If you use which Command view python edition , What you still see is the built-in version of the system , While using pip Command, you will be prompted that the command cannot be found .

$ which python
/usr/bin/python

This is because you have not set the default enabled python and pip file . To enable a certain version of the program, you can use port select Command to view and select , Want to know select Commands can be used $man port To view the .

$ man port
...
select
For a given group, selects a version to be the default by creating appropriate symbolic links. For instance, python might be linked to python2.. Available select groups are installed as subdi-
rectories of ${prefix}/etc/select/. To list the available versions in a group, use --list. To see which version is currently selected for a group, use --show. To change the selected version for
a group, use --set. For example: port select --list python
port select --show gcc
port select --set gcc mp-gcc44
...

MacPorts Different versions of the same program are grouped , Each version has its own name , By specifying the group name and the exclusive name, you can enable a specific version of the program .

Let's take a look python The grouping :

$ port select --list python
Available versions for python:
none (active)
python25-apple
python26-apple
python27
python27-apple

Now let's enable the just installed python27, This needs to be sudo jurisdiction :

$ port select --set python python27
Selecting 'python27' for 'python' failed: could not create new link "/opt/local/bin/python" pointing to "/opt/local/bin/python2.7": permission denied $ sudo port select --set python python27
Password:
Selecting 'python27' for 'python' succeeded. 'python27' is now active. $ port select --list python
Available versions for python:
none
python25-apple
python26-apple
python27 (active)
python27-apple $ which python
/opt/local/bin/python $ python
Python 2.7. (default, Nov , ::)
[GCC 4.2. Compatible Apple LLVM 5.0 (clang-500.2.)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

You can see that the first time there was no sudo jurisdiction , operation failed . After setting, it will display python27 In the active state . Empathy , Enable pip:

$ port select --list pip
Available versions for pip:
none (active)
pip27 $ sudo port select --set pip pip27
Selecting 'pip27' for 'pip' succeeded. 'pip27' is now active. $ port select --list pip
Available versions for pip:
none
pip27 (active) $ pip Usage:
pip <command> [options] Commands:
install Install packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
zip DEPRECATED. Zip individual packages.
unzip DEPRECATED. Unzip individual packages.
bundle DEPRECATED. Create pybundles.
help Show help for commands. General Options:
-h, --help Show help.
-v, --verbose Give more output. Option is additive, and can be used up to times.
-V, --version Show version and exit.
-q, --quiet Give less output.
--log-file <path> Path to a verbose non-appending log, that only logs failures. This log is active by default at /Users/Xavier/.pip/pip.log.
--log <path> Path to a verbose appending log. This log is inactive by default.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--timeout <sec> Set the socket timeout (default seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
--cert <path> Path to alternate CA bundle.

thus , You can use it python 2.7.6 and pip 了 .

Add :Homebrew Will not override those that should be native installed in OS X Documents in . This means that if a native package is updated ,Homebrew It will notify you instead of covering it . It can also install the package in the user's own directory , So you don't have to use sudo To install , This installation means that all access paths are valid for you , So we can get rid of the dependence on the system library . in addition Homebrew There is an active community , So updates are very fast .

[OSX] Use MacPorts install Python and pip More articles on the guide

  1. windows The following installation Python and pip The ultimate course

    When I was a sophomore, I had contact with Python, Recently I started to play the language again . in general , individual People like it very much Python Language style of , But this language is very important for windows Not very friendly , Because if it's a beginner in windows Installation in environment ...

  2. turn : windows The following installation Python and pip The ultimate course

    original text : http://www.cnblogs.com/yuanzm/p/4089856.html Because if it's a beginner in windows Installation in environment , It's torture , There are all kinds of egg pains . This article hopes to provide a fool like teaching ...

  3. windows The following installation Python and pip

    windows The following installation Python and pip install Python First step , Let's install Python, https://www.python.org/downloads/ The choice here is 2.7.10 The second step . ...

  4. Python Study windows The following installation Python and pip( One )

    windows The following installation Python and pip install Python First step , Let's install Python, https://www.python.org/downloads/ The choice here is 2.7.10 The second step . ...

  5. install Python and pip

    windows The following installation Python and pip The ultimate course When I was a sophomore, I had contact with Python, Recently I started to play the language again . in general , I like it very much Python Language style of , But this language is very important for windows It's not ...

  6. install python Of pip modular

    install python Of pip modular website https://pypi.python.org/pypi/pip choice , Click to download Extract the file to C:\Users\Administrator\AppData\Local ...

  7. linux install python,pip,

    Linux Next python Upgrade steps http://www.cnblogs.com/lanxuezaipiao/archive/2012/10/21/2732864.html stay  https://www. ...

  8. linux install python and pip

    Download the file python Official website :https://www.python.org/downloads/ Baidu SkyDrive http://pan.baidu.com/s/1mixGB12     password    9nzu [r ...

  9. linux Lower installation python and pip

    Be careful : Don't unload the original easily python Environmental Science , Because some software depends on him One : Before the installation , First, install the dependent environment together , Avoid repeated compilation later [root@redhat2 bin]# yum install gcc g++ ...

Random recommendation

  1. nginx+tomcat+dubbo Single deployment of multiple dubbo application

    The previous blog has explained how to use it nginx+tomcat, What we are doing today is how to deploy multiple servers on a single server dubbo Clusters of applications . Because of this problem encountered in the project , Write it down today . 1.

  2. Java Strengthen the basic knowledge IO Stream notes 20:FileOutputStream Write data to achieve line feed and add write

    1.   How to realize the line feed of data ? (1) package com.himi.fileoutputstream; import java.io.FileNotFoundException; import j ...

  3. Android in bitmap Related treatment

    Load big pictures Options options=new Options(); options.inJustDecodeBounds=true;// Don't load pictures , Load only file information // Loading pictures , Get configuration information ...

  4. python Way of learning -3 initial python Data types and file operations

    This article deals with set aggregate function The ternary operation File operations set aggregate set Is an unordered and unrepeatable set of elements 1. establish set The way to assemble 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...

  5. handy git Warehouse Establishment , Remote push-pull and common git Orders and parts Linux Order collection

    Method 1 : Directly in GitHub Build a project on , then git clone (git address name): At this point, a git Warehouse : cd Folder > Add files in >git add ...

  6. PHP serialize / The method function of deserialization

    In the process of development, we often encounter the need to store the sequence number of objects or arrays , Deserializing the output . Especially when you need to store arrays in mysql Database time , We often need to sequence the array . serialize ( Serialization ): Is to convert a variable to a saveable ...

  7. HTML5 Play RTSP,H5 Play RTSP, Solution source code , Based on Haikang webcam

    The video is from Haikang webcam ( Support RTSP, standard H.264 RTP Packaged devices ), Can pass  rtsp://admin:1008@192.0.0.64:81/h264/ch1/main/av_stream   ...

  8. MFC Control programming progress bar writing

    MFC Control programming progress bar writing One, the progress bar programming needs to use the method Progress bar MFC We've already encapsulated the class for us . be called  CProgressCtrl  Progress bar programming is also very simple . There are only a few encapsulation methods . GetPos()  a ...

  9. 025 How to use it github Bind your own domain name

    This used to look at documents at the same time , I recently reconfigured , Still feel at the same time this document is very good , No more rewriting , Copy only one connection . https://blog.csdn.net/iliujie/article/detail ...

  10. The first 1 course Type derivation (1)_auto keyword

    1.  auto keyword (1)auto The function of the compiler is to let the compiler automatically infer the type of the variable , You don't need to explicitly specify the type . This implicit type derivation occurs at compile time . (2)auto Does not represent the actual type declaration , Just a type declaration “ Place holder ” ...