博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
osx python 位置_在OSX(和必要的模块)上安装Python
阅读量:2518 次
发布时间:2019-05-11

本文共 5082 字,大约阅读时间需要 16 分钟。

osx python 位置

If you need help installing python on OSX, read on.

如果您需要在OSX上安装python的帮助,请继续阅读。

For the last three years, I’ve used a mac for all my development. I love the fact that everything ‘just works’ on the platform. That said, when you get into scientific computing and data analytics, especially with python, you can  run into some issues.

在过去的三年中,我一直使用Mac进行开发。 我喜欢在平台上一切都“正常运行”的事实。 也就是说,当您进入科学计算和数据分析领域时,尤其是使用python时,可能会遇到一些问题。

Just like linux, python is included with the operating system. Unlike linux, this can cause problems long-term for you due to upgrades and changes that Apple may make to the python ecosystem.

就像linux一样,python也包含在操作系统中。 与linux不同,这可能会因Apple可能对python生态系统进行升级和更改而给您带来长期问题。

On OS X, I recommend those of you starting out to go with  or .  As I said in ““, I prefer Canopy over Anaconda for scientific computing / data analytics but either will work for you.  Installing Canopy on the mac is very similar to installing it on Windows…so I’ll let .

在OS X上,我建议那些开始使用或 。 正如我在“ ”中所说的那样,在科学计算/数据分析方面,我更喜欢Canopy而不是Anaconda,但两者都可以为您工作。 在Mac上安装Canopy与在Windows上安装非常相似...因此,我将以 。

If you want to get into the nitty-gritty and install and configure python and the modules yourself, you can easily do so, but be prepared to spend some time on the command line.

如果您想进入nitty-gritty并自己安装和配置python及其模块,则可以轻松地做到这一点,但要准备在命令行上花一些时间。

Before we get started installing python on your Mac, we need to install , which is a package manager for OS X (it acts similar to the ‘apt’ package manager on ubuntu / debian).

在我们开始在Mac上安装python之前,我们需要安装 ,它是OS X的软件包管理器(其作用类似于ubuntu / debian上的“ apt”软件包管理器)。

To install homebrew, open a terminal and paste the following:

要安装自制软件,请打开终端并粘贴以下内容:

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

This command installs the homebrew ecosystem onto your machine and preps your machine to be ready to install various packages, including python.

此命令将自制软件生态系统安装到您的计算机上,并使您的计算机准备就绪,可以安装各种软件包,包括python。

在OSX上安装Python (Installing Python on OSX)

Step 1: Let’s get python installed via homebrew.  In your terminal, type:

步骤1:让我们通过自制软件安装python。 在您的终端中,键入:

brew install python

This will install a version of python onto your machine and set up your environment to use that version. This helps mitigate any issues you might have down the road if / when Apple makes changes to the system provided python.   Additionally, brew installs pip into the system to make it easy to get the necessary modules onto your machine.

这会将python版本安装到您​​的计算机上,并设置您的环境以使用该版本。 如果/当Apple对系统提供的python进行更改时,这有助于减轻您可能遇到的任何问题。 此外,brew将pip安装到系统中,以便轻松将必要的模块安装到计算机上。

From this point on, we are generally going to follow exactly the same steps that I outline in  except we don’t need to install any additional tools.

从这一点开始,我们通常将遵循与我概述的步骤完全相同的步骤,只是不需要安装任何其他工具。

Step 2: Not required, but highly recommended – install a virtual environment.  I recommend virtualenv. Install it with this command:

步骤2:不是必需的,但强烈建议 -安装虚拟环境。 我推荐virtualenv。 使用以下命令安装它:

pip install virtualenv

When you are ready to get started on a new project, type the below command to install python into a new virtual environment (the ‘env’ is the name of the environment). You only have to do this once per project. Note: You should use a folder per project to keep your virtual environments separated.

当您准备开始新项目时,请键入以下命令以将python安装到新的虚拟环境中(“ env”是环境的名称)。 每个项目只需执行一次。 注意:您应该为每个项目使用一个文件夹,以保持虚拟环境分离。

virtualenv env

Whenever you want to work on a specific project, change into that folder and type the following. This will set up your environment with all of your installed python modules:

每当您要处理特定项目时,请切换到该文件夹​​并键入以下内容。 这将使用所有已安装的python模块设置您的环境:

source env/bin/activate

For the purpose of this walk-through let’s create a new directory, set up a new virtual environment and then install the necessary modules.

为了完成本演练,让我们创建一个新目录,设置一个新的虚拟环境,然后安装必要的模块。

  • Create a folder in your home directory called ‘projects’.
  • Type “mkdir projects” to do this from the command line.
  • Change into that folder and then type “mkdir install_example” to create another folder inside the projects folder.
  • Type “virtualenv env” to create your virtual environment.
  • Type “source env/bin/activate” to begin using this environment
  • 在您的主目录中创建一个名为“ projects”的文件夹。
  • 在命令行中键入“ mkdir projects”以执行此操作。
  • 转到该文件夹​​,然后键入“ mkdir install_example”以在项目文件夹中创建另一个文件夹。
  • 输入“ virtualenv env”以创建您的虚拟环境。
  • 输入“ source env / bin / activate”以开始使用此环境

Now that we have our environment ready to go, we need to install some of the modules that are most often used when doing data work inside python. These modules are:

现在我们已经准备好环境,我们需要安装一些在python中进行数据工作时最常用的模块。 这些模块是:

  •  (installed when you install pandas with pip)
  • (通过pip安装pandas时安装)

The above modules can be installed with one pip command.

可以使用一个pip命令安装以上模块。

pip install pandas scipy scikitlearn statsmodels sympy matplotlib jupyter

You’re ready to start working with python for data analysis on your mac. Just remember, for each virtualenv you create, you’ll need to reinstall these modules if you wish to use them.

您已经准备好开始使用python在Mac上进行数据分析。 请记住,对于您创建的每个virtualenv,如果要使用它们,都需要重新安装这些模块。

翻译自:

osx python 位置

转载地址:http://veqwd.baihongyu.com/

你可能感兴趣的文章
NSTextView 文字链接的定制化
查看>>
第五天站立会议内容
查看>>
ATMEGA16 IOport相关汇总
查看>>
JAVA基础-多线程
查看>>
面试题5:字符串替换空格
查看>>
[Codevs] 线段树练习5
查看>>
Amazon
查看>>
component-based scene model
查看>>
Echart输出图形
查看>>
hMailServer搭建简单邮件系统
查看>>
从零开始学习jQuery
查看>>
Spring+SpringMVC+MyBatis深入学习及搭建(四)——MyBatis输入映射与输出映射
查看>>
opacity半透明兼容ie8。。。。ie8半透明
查看>>
CDOJ_24 八球胜负
查看>>
Alpha 冲刺 (7/10)
查看>>
一款jQuery打造的具有多功能切换的幻灯片特效
查看>>
SNMP从入门到开发:进阶篇
查看>>
@ServletComponentScan ,@ComponentScan,@Configuration 解析
查看>>
unity3d 射弹基础案例代码分析
查看>>
thinksns 分页数据
查看>>