Python 为什么 apt-get 功能在 Mac OS X v10.9 (Mavericks) 的终端中不起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19688424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why is the apt-get function not working in the terminal on Mac OS X v10.9 (Mavericks)?
提问by user2800761
I was watching this, and, as you can see, the first command I am told to put in is:
我正在看这个,正如你所看到的,我被告知要输入的第一个命令是:
sudo apt-get install python-setuptools
When I do this, it outputs:
当我这样做时,它输出:
sudo: apt-get: command not found
I have no idea why this is the case.
我不知道为什么会这样。
How can I resolve this so I am following the tutorial correctly?
我该如何解决这个问题,以便我正确地遵循教程?
回答by George Stocker
Mac OS X doesn't have apt-get
. There is a package manager called Homebrewthat is used instead.
Mac OS X 没有apt-get
. 有一个名为Homebrew的包管理器被用来代替。
This command would be:
此命令将是:
brew install python
酿造安装蟒蛇
Use Homebrew to install packages that you would otherwise use apt-get
for.
使用 Homebrew 安装您原本会使用的软件包apt-get
。
The page I linked to has an up-to-date way of installing homebrew, but at present, you can install Homebrew as follows:
我链接到的页面有最新的安装 homebrew 的方法,但目前,您可以按如下方式安装 Homebrew:
Type the following in your Mac OS X terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
在 Mac OS X 终端中键入以下内容:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After that, usage of Homebrew is brew install <package>
.
之后,Homebrew 的用法是brew install <package>
.
One of the prerequisites for Homebrew are the XCode command line tools.
Homebrew 的先决条件之一是 XCode 命令行工具。
- Install XCode from the App Store.
- Follow the directions in this Stack Overflow answer to install the XCode Command Line Tools.
- 从 App Store 安装 XCode。
- 按照此Stack Overflow 答案中的说明安装 XCode 命令行工具。
Background
背景
A package manager (like apt-get
or brew
) just gives your system an easy and automated way to install packages or libraries. Different systems use different programs. apt
and its derivatives are used on Debian based linux systems. Red Hat-ish Linux systems use rpm
(or at least they did many, many, years ago). yum
is also a package manager for RedHat based systems.
包管理器(如apt-get
或brew
)只是为您的系统提供了一种简单且自动化的方式来安装包或库。不同的系统使用不同的程序。 apt
及其衍生产品用于基于 Debian 的 linux 系统。Red Hat-ish Linux 系统使用rpm
(或者至少他们在很多很多年前使用过)。 yum
也是基于 RedHat 的系统的包管理器。
Alpine based systems use apk
.
基于 Alpine 的系统使用apk
.
Warning
警告
As of 25 April 2016, homebrew opts the user in to sending analytics by default. This can be opted out of in two ways:
截至 2016 年 4 月 25 日,自制软件默认选择用户发送分析。可以通过两种方式选择退出:
Setting an environment variable:
设置环境变量:
- Open your favorite environment variable editor.
- Set the following:
HOMEBREW_NO_ANALYTICS=1
in whereever you keep your environment variables (typically something like~/.bash_profile
) - Close the file, and either restart the terminal or
source ~/.bash_profile
.
- 打开您最喜欢的环境变量编辑器。
- 设置以下内容:
HOMEBREW_NO_ANALYTICS=1
在您保存环境变量的任何地方(通常类似于~/.bash_profile
) - 关闭文件,然后重新启动终端或
source ~/.bash_profile
.
Running the following command:
运行以下命令:
brew analytics off
the analytics status can then be checked with the command:
然后可以使用以下命令检查分析状态:
brew analytics
回答by Günther Jena
回答by esmit
MacPortsis another package manager for OS X:.
MacPorts是另一个适用于 OS X: 的包管理器。
Installation instructions are at The MacPorts Project -- Download & Installationafter which one issues sudo port install pythonXX
, where XX
is 27
or 35
.
安装说明位于MacPorts 项目 - 下载和安装,然后发布一个问题sudo port install pythonXX
,XX
是27
或35
。
回答by NadZ
You can also use the curl command for installing things, wherever apt-getis mentioned with a URL...
您还可以使用 curl 命令来安装东西,只要apt-get用 URL 提及...
For example,
例如,
curl -O http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz