我需要安装多少个 macports

发布于 2024-12-21 10:15:18 字数 653 浏览 0 评论 0原文

在过去的几个月里,我开始使用 Wing IDE 来完成我的大部分编程。我选择 Wing 主要是因为它与 wxPython 配合得很好,使我的调试速度比将 TextWrangler 与 Terminal 一起使用时要快得多。然而,Wing 的一个怪癖是没有令人满意的方法来强制 Python 的通用构建在 32 位模式下运行。由于我使用的是 wxPython 2.8.x(仅 32 位),因此我使用仅 32 位版本的 python 作为可执行文件(2.7.1)。只要我只使用 python 标准库和 wxPython,我就没有问题,但当我开始尝试安装第三方模块来使用这个 32 位版本的 Python 时,我的麻烦就开始了。我想使用 macports 进行所有安装,但似乎我下载的 macports 安装的模块只能与恰好通用的不同版本的 python 一起使用。本质上这是一个关于 macports 的问题,我希望澄清以下两点:

  1. 如果我想在我的计算机上安装三个版本的 python(例如 2.6、2.7 和 3.2),并且想要使用 macports 为每个版本安装模块其中,我需要三个单独版本的 macports - 每个 python 一个吗?
  2. 如果我对(1)的看法是正确的,我该如何开始安装单独的版本?我查看了 macports 网站,但找不到基于您想要使用的 python 版本的替代版本的参考,

非常感谢帮助。

Over the past couple of months I've set about using Wing IDE to do the vast majority of my programming. I chose Wing primarily because it works well with wxPython, allowing me to debug much more quickly than was the case when I was using TextWrangler alongside Terminal. A quirk of Wing however is that there is no satisfactory way to force universal builds of python to run in 32-bit mode. Since I'm using wxPython 2.8.x (32-bit only) I'm using a 32-bit-only version of python as the executable (2.7.1). So long as I'm only using the python standard library and wxPython I have no problems, my trouble begins when I start trying to install third-party modules to work with this 32-bit version of Python. I want to do all my installing using macports, but it appears that the macports I have downloaded installs modules for use only with a different version of python that happens to be universal. Essentially then this is a question about macports, and I'd appreciate clarification on the following two points:

  1. If I want three versions of python on my computer (say 2.6, 2.7 and 3.2), and want to use macports to install modules for each of them, do I need three separate versions of macports - one for each python?
  2. If I'm right about (1) how do I set about installing separate versions? I've looked on the macports website but can find no reference to alternative versions based on which version of python you want to use it with

Help much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沙沙粒小 2024-12-28 10:15:18

安装在 /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 的 Python 几乎肯定与 MacPorts 无关。您可能是通过 python.org 安装程序安装的。如果您想向其安装软件包,则应使用 安装单独版本的 easy_install直接为其分发包和/或pip使用它们为该 Python 实例安装包。这些版本将安装在框架 bin 目录中,/Library/Frameworks/Python.framework/Versions/2.7/bin。您无法从 MacPorts 管理它的 Python 包;仅适用于 MacPorts Python,即位于 /opt/local/bin

看来您安装了三个版本的 Python 2.7。 Apple 提供的系统 Python 位于 /usr/bin/python2.7,MacPorts 安装的版本位于 /opt/local/bin/python2.7,以及第三个版本(可能来自 python.org)位于 /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 (可能有一个符号链接/usr/local/bin/python2.7)。安装这三个软件本身并没有什么问题,而且这三个软件可以轻松共存。只需记住您正在使用哪一个,无论是通过管理 shell 路径还是使用每个路径的绝对路径,并且安装的任何其他包都需要安装到正确的 Python 站点包目录中。如果您使用 easy_installpip,则需要分别安装和/或使用正确的安装程序。

如果您的目标只是将 wx-python 与 Python 2.7 结合使用,那么构建仅 32 位版本的 wx-python 会遇到一个突出的 MacPorts 问题,因为它的对已弃用的 OS X Carbon API 的依赖。似乎有一个新的 MacPorts 端口 wxWidgets 的 Cocoa 版本,应该在 64 位模式下工作。您可能想尝试一下:

sudo port selfupdate
sudo port install py27-wxpython-devel

A Python installed at /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 almost certainly has nothing to do with MacPorts. You probably installed it from a python.org installer. If you want to install packages to it, you should install separate versions of easy_install using the Distribute package and/or pip for it and directly install packages for that Python instance with them. Those versions will be installed in the framework bin directory, /Library/Frameworks/Python.framework/Versions/2.7/bin. You can't manage Python packages for it from MacPorts; that works only for MacPorts Pythons, i.e. at /opt/local/bin.

So it appears you have three versions of Python 2.7 installed. The Apple-supplied system Python at /usr/bin/python2.7, a MacPorts-installed version at /opt/local/bin/python2.7, and a third (possibly from python.org) at /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 (for which there is likely a symlink at /usr/local/bin/python2.7). There's nothing inherently wrong about having all three installed and the three can easily co-exist. Just keep in mind which one you are using, either by managing your shell path or using an absolute path to each, and that any additional packages installed need to be installed to the correct Python's site-packages directory. If you use easy_install or pip, you need to install and/or use the correct one for each.

If your goal is just to use wx-python with Python 2.7, there is an outstanding MacPorts issue about building a 32-bit-only version of wx-python because of its dependency on deprecated OS X Carbon APIs. There appears to be a new MacPorts port of a Cocoa version of wxWidgets which should work in 64-bit mode. You might want to experiment with it:

sudo port selfupdate
sudo port install py27-wxpython-devel
明月松间行 2024-12-28 10:15:18

不,你不需要单独版本的 macport,你需要的是单独版本的 python。

明确的步骤:

  1. 安装 macports。之后您应该能够使用 port 命令。如果您使用的是 Mac 版安装程序,您的路径中应该自动将 /opt/local/bin 放在首位。
  2. 安装 python 2.6 - sudo port install python26
  3. 安装 python 2.7 - sudo port install python27
  4. 您可以通过 /opt/local/bin/python2.6 使用 python26 code>
  5. 您可以通过/opt/local/bin/python2.7使用python27

  6. 如果您想使用 python27 作为默认值,请执行sudo port python-select python27。这将确保 /opt/local/bin/python 链接到 /opt/local/bin/python2.7

Mac 附带默认的 python 安装,未删除。可以从 /usr/bin/python 访问它。

Macports 将其工具安装在路径 /opt/local 下,并将二进制文件安装在 /opt/local/bin 下。因此,现在您将拥有多个版本的 python 并位于不同的位置,以便您可以选择运行哪一个。

使用特定版本的 python 安装的软件包将进入其站点软件包,并且不适用于其他版本的 python 安装。

[编辑:基于评论]

我有多个版本的标准 python 安装。

~ $ /usr/bin/python
python            python2.5         python2.6         pythonw           pythonw2.6        
python-config     python2.5-config  python2.6-config  pythonw2.5 

使用 python2.5,我得到:

>>> print platform.architecture()
('32bit', '')
>>> sys.maxint > 2**32
False

使用 python2.6,我得到:

>>> print platform.architecture()
('64bit', '')
>>> sys.maxint > 2**32
True

请参阅 - http: //docs.python.org/library/platform.html

No you don't need separate versions of macport, what you need is separate versions of python.

Clear steps to do it :

  1. Install macports. You should be able to use port command after that. You should have /opt/local/bin first in your path automatically, if you are using the installer for Mac.
  2. Install python 2.6 - sudo port install python26
  3. Install python 2.7 - sudo port install python27
  4. You can use python26 through /opt/local/bin/python2.6
  5. You can use python27 through /opt/local/bin/python2.7

  6. If you want to use the python27 as default then do a sudo port python-select python27. This will ensure that /opt/local/bin/python is linked to /opt/local/bin/python2.7.

Mac comes with default python installation which is not removed. It can be accessed from /usr/bin/python.

Macports installs it's tools under path /opt/local and binaries at /opt/local/bin. So now you will have multiple versions of python and located at different location so that you can choose which one to run.

The packages installed with a particular version of python will go in it's site-packages and will not be available to other versions of python installation.

[Edit: based on comments]

I have multiple versions of standard python installation.

~ $ /usr/bin/python
python            python2.5         python2.6         pythonw           pythonw2.6        
python-config     python2.5-config  python2.6-config  pythonw2.5 

With python2.5, I get:

>>> print platform.architecture()
('32bit', '')
>>> sys.maxint > 2**32
False

With python2.6, I get:

>>> print platform.architecture()
('64bit', '')
>>> sys.maxint > 2**32
True

See the note at - http://docs.python.org/library/platform.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文