问题:为什么apt-get功能在Mac OS X v10.9(Mavericks)的终端中不起作用?

我正在观看此视频,如您所见,告诉我的第一个命令是:

sudo apt-get install python-setuptools

当我这样做时,它输出:

sudo: apt-get: command not found

我不知道为什么会这样。

如何解决此问题,以便正确遵循本教程?

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?


回答 0

Mac OS X没有apt-get。有一个叫做Homebrew的程序包管理器代替了。

该命令将是:

brew安装python

使用Homebrew安装否则会用到的软件包apt-get

我链接到的页面具有安装Homebrew的最新方法,但是目前,您可以按以下方式安装Homebrew:

在Mac OS X终端中键入以下内容:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

在那之后,Homebrew的用法为brew install <package>

XCode命令行工具是Homebrew的前提条件之一。

  1. 从App Store安装XCode。
  2. 请按照此Stack Overflow答案中的说明安装XCode命令行工具

背景

软件包管理器(如apt-getbrew)只是为您的系统提供了一种简单且自动化的安装软件包或库的方法。不同的系统使用不同的程序。 apt及其派生类在基于Debian的linux系统上使用。使用Red Hat式的Linux系统rpm(或者至少在很多年前,他们做了很多)。 yum还是基于RedHat的系统的软件包管理器。

基于高山的系统使用apk

警告

自2016年4月25日起,默认情况下自制软件会选择让用户加入分析。可以通过两种方式选择退出:

设置环境变量:

  1. 打开您喜欢的环境变量编辑器
  2. 进行以下设置:HOMEBREW_NO_ANALYTICS=1 在保存环境变量的任何地方(通常是~/.bash_profile
  3. 关闭文件,然后重新启动终端或source ~/.bash_profile

运行以下命令:

brew analytics off

然后可以使用以下命令检查分析状态:

brew analytics

Mac OS X doesn’t have apt-get. There is a package manager called Homebrew that is used instead.

This command would be:

brew install python

Use Homebrew to install packages that you would otherwise use apt-get for.

The page I linked to has an up-to-date way of installing homebrew, but at present, you can install Homebrew as follows:

Type the following in your Mac OS X terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After that, usage of Homebrew is brew install <package>.

One of the prerequisites for Homebrew are the XCode command line tools.

  1. Install XCode from the App Store.
  2. Follow the directions in this Stack Overflow answer to install the XCode Command Line Tools.

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.

Alpine based systems use 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:

Setting an environment variable:

  1. Open your favorite environment variable editor.
  2. Set the following: HOMEBREW_NO_ANALYTICS=1 in whereever you keep your environment variables (typically something like ~/.bash_profile)
  3. Close the file, and either restart the terminal or source ~/.bash_profile.

Running the following command:

brew analytics off

the analytics status can then be checked with the command:

brew analytics

回答 1

因为Homebrew是我在macOS上的最爱,尽管有可能apt-get使用Fink在macOS上使用。

As Homebrew is my favorite for macOS although it is possible to have apt-get on macOS using Fink.


回答 2

MacPorts是OS X的另一个软件包管理器:。

安装说明在该MacPorts的项目-下载和安装之后,一个问题sudo port install pythonXX,这里XX2735

MacPorts is another package manager for OS X:.

Installation instructions are at The MacPorts Project — Download & Installation after which one issues sudo port install pythonXX, where XX is 27 or 35.


回答 3

Conda也可以用作程序包管理器。可以从Anaconda安装。

另外,一个免费的最小安装程序是Miniconda

Conda can also be used as package manager. It can be installed from Anaconda.

Alternatively, a free minimal installer is Miniconda.


回答 4

您还可以使用curl命令安装东西,只要在URL提及apt-get的地方…

例如,

curl -O http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz

Alternatively You can use the brew or curl command for installing things, wherever apt-get is mentioned with a URL…

For example,

curl -O http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。