我喜欢将 Python 与 numpy、scipy 和其他一些软件包一起使用.我是一个绝对的 Python 初学者,在 Mac OS X 下安装时遇到了一些问题.
I like to use Python with numpy, scipy and some other packages. I am an absolute Python beginner and have some issues with the installation under Mac OS X.
我正在按照以下两个教程安装python:1 和 2.
I am following these two tutorials to install python: 1 and 2.
这里,HomeBrew 用于安装 Python(带有 pip)和 virtualenv.我对什么更好没有意见,MacPorts、HomeBrew、Fink...我只是发现本教程激发了信心.
Here, HomeBrew is used to install Python (with pip) and virtualenv. I do not have an opinion about what is better, MacPorts, HomeBrew, Fink... I just found this tutorial inspiring confidence.
如果我理解正确的话,我不应该接触的 OS X 系统 Python 位于/System/Library/Frameworks/Python.Framework 下.而且我不能在 Xcode 中使用这个,因为它没有我想要的包.HomeBrew Python 将安装在/usr/local/中的某个位置.我在那里找到了一个框架,但作为系统框架,它没有额外的包.本教程解释说,最好只在虚拟环境中安装额外的包,这通过 pip 完成.但我在那里找不到框架.
If I understand things correctly, OS X system Python, which I should never touch, is under /System/Library/Frameworks/Python.Framework. And I cannot use this one in Xcode because it does not have my wanted packages. The HomeBrew Python will be installed somewhere in /usr/local/. I found a framework there but as the system framework it does not have the additional packages. The tutorial explains that it might be better to install additional packages in virtual environments only which is done via pip. But I cannot find a framework there.
所以我的问题是:如何在包含可以包含到 Xcode 中的框架的虚拟环境中安装 Python?
So my question is: How can I get a Python installation in a virtual environment that includes a framework that I can include into Xcode?
但如果您愿意,您可以安装其他版本的 Python(64 位,而不是 32 位!):
But if you want, you can install others versions of Python (in 64-bits, not 32 !):
a) Apple 规定的方式:作为框架
您必须在 /usr/bin 中更改 Python 可执行文件的 PATH(通常,这是通过符号链接或在 /Users/me/.bash_profile 文件).
You must change the PATH of the Python executable in /usr/bin (usually, this is done automatically by the distribution by symlinks or in the /Users/me/.bash_profile file ).
安装在 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages 中的模块不会干扰安装在 /Library/Python 中的模块/2.7/site-packages 如果您使用适当的 Python 可执行文件,反之亦然.
The modules installed in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages do not interfere with those installed in /Library/Python/2.7/site-packages if you use the appropriate Python executable and viceversa.
b) 包管理系统方式
MacPorts 在文件夹 /opt/ 中安装自己的 Python 版本;
MacPorts install its own version of Python in the folder /opt/;
sudo port -v install python27
sudo port -v install python27
Fink 在文件夹 /sw/ 中安装自己的 Python 版本;
Fink install its own version of Python in the folder /sw/;
fink 安装 Python27
fink install Python27
Homebrew 在 /usr/local/Cellar 中安装 Python,并在 /usr/local/bin 中使用符号链接.
Homebrew installs Python in /usr/local/Cellar with symlinks in /usr/local/bin.
brew安装python
或
brew install python --framework
brew install python
or
brew install python --framework
要使用它们,您必须将 /sw/bin、/sw/lib/或/opt/bin、/opt/lib/ 添加到 PATH 并更改Python 可执行文件
To use them, you must add /sw/bin, /sw/lib/ or /opt/bin, /opt/lib/ to the PATH and change the PATH of the Python executable
c) 自主"方式
d) 硬"的方式
所以你的问题:
如何在包含可包含在 Xcode 中的框架的虚拟环境中安装 Python?
How can I get a Python installation in a virtual environment that includes a framework that I can include into Xcode?
除非您是 Unix 专家(路径管理),否则您必须使用 Apple 推荐的解决方案,即框架分发(包括 Apple Python)
Unless you are a Unix specialist (PATHs management) , you must use the Apple's recommended solution, a frameworks distribution (including the Apple Python)
这篇关于在 Mac OS X 虚拟环境中安装 Python,其中包含我可以包含到 Xcode 中的框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!