我开始学习 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 开发人员使用什么方法来管理他们的模块?
额外问题:
你用的是苹果的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),我会选择 macports python 2.6.
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 模块最兼容的方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!