在Mac上安装python模块的最兼容方法是什么? [英] What is the most compatible way to install python modules on a Mac?

查看:89
本文介绍了在Mac上安装python模块的最兼容方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始学习python并热爱它.我主要在Mac和Linux上工作.当我使用apt-get安装python模块时,在Linux(主要是Ubuntu 9.04)上发现了这一点,效果很好.我可以轻松导入它.

I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.

在Mac上,我习惯于使用Macports安装所有Unixy东西.但是,我发现我安装的大多数python模块都没有被python看到.我花了一些时间使用PATH设置并使用python_select.什么都没有真正起作用,在这一点上我还不是很了解,相反,我只是闲逛.

On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm finding that most of the python modules I install with it are not being seen by python. I've spent some time playing around with PATH settings and using python_select . Nothing has really worked and at this point I'm not really understanding, instead I'm just poking around.

我给人的印象是Macports在管理python模块方面并不是普遍喜欢的.我想使用一种更加接受"(如果正确的话)的方法重新开始.

I get the impression that Macports isn't universally loved for managing python modules. I'd like to start fresh using a more "accepted" (if that's the right word) approach.

所以,我想知道Mac python开发人员用来管理其模块的方法是什么?

奖金问题:

您使用Apple的python还是其他版本? 您是从源代码编译所有内容,还是有一个运行良好的软件包管理器(Fink?).

Do you use Apple's python, or some other version? Do you compile everything from source or is there a package manger that works well (Fink?).

推荐答案

管理python软件包的最流行方法(如果您未使用系统软件包管理器)是使用setuptools和easy_install.它可能已经安装在您的系统上.像这样使用它:

The most popular way to manage python packages (if you're not using your system package manager) is to use setuptools and easy_install. It is probably already installed on your system. Use it like this:

easy_install django

easy_install使用 Python包索引,这对于python开发人员来说是一个了不起的资源.环顾四周,看看有哪些软件包可用.

easy_install uses the Python Package Index which is an amazing resource for python developers. Have a look around to see what packages are available.

一个更好的选择是 pip ,由于它试图解决了许多与easy_install相关的问题. Pip使用与easy_install相同的软件包存储库,但效果更好.真正唯一需要使用easy_install的时间是此命令:

A better option is pip, which is gaining traction, as it attempts to fix a lot of the problems associated with easy_install. Pip uses the same package repository as easy_install, it just works better. Really the only time use need to use easy_install is for this command:

easy_install pip

之后,使用:

pip install django

在某个时候,您可能想了解一些有关 virtualenv 的知识.如果您在软件包需求冲突的项目上进行大量python开发,那么virtualenv是天赐之物.它将使您可以使用各种软件包的完全不同的版本,并根据需要在它们之间轻松切换.

At some point you will probably want to learn a bit about virtualenv. If you do a lot of python development on projects with conflicting package requirements, virtualenv is a godsend. It will allow you to have completely different versions of various packages, and switch between them easily depending your needs.

关于要使用哪个python,坚持使用Apple的python会让您头疼最少,但是如果您需要更新的版本(我认为Leopard是2.5.1),我会选择

Regarding which python to use, sticking with Apple's python will give you the least headaches, but If you need a newer version (Leopard is 2.5.1 I believe), I would go with the macports python 2.6.

这篇关于在Mac上安装python模块的最兼容方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆