Mac OS X虚拟环境中的Python安装是否包括我可以包含在Xcode中的框架? [英] Python installation in Mac OS X virtual environment that includes a framework that I can include into Xcode?

查看:112
本文介绍了Mac OS X虚拟环境中的Python安装是否包括我可以包含在Xcode中的框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢将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?

推荐答案

  1. Apple Python可以正常使用,并且正常的site-packages文件夹为/Library/Python/2.7/site-packages (而不是/System/Library/Frameworks/Python.framework/版本/2.7/lib/python2.7/site-packages ).您可以毫无问题地使用它.
  2. 对于我想要作为框架的所有模块(numpy,scipy,matplotlib,pandas,shapely和其他...),或者使用pip或easy_install,包括virtualenv(仅以常规方式安装它们),我都没有问题Python)或创建虚拟环境.
  3. 在安装框架模块时,它会放置在普通的site-packages文件夹中.
  4. 唯一的问题可能是旧" Python版本(使用2.6.x,2.7.x和3.3.x版本对我来说不是问题)
  1. The Apple Python is functional and the normal site-packages folder is /Library/Python/2.7/site-packages (and not /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages). You can use it without problem.
  2. I never had any problem to install all modules (numpy, scipy, matplotlib, pandas, shapely, and others...) that I wanted as frameworks, or with pip or easy_install, including virtualenv (simply install them in the conventional way in Python) or creating virtual environments.
  3. when you install a framework module, It is placed in in the normal site-packages folder.
  4. the only problem is possibly the "old" Python version (not a problem for me, using 2.6.x, 2.7.x and 3.3.x versions)

但是,如果需要,您可以安装其他版本的Python(64位而不是32位!):

But if you want, you can install others versions of Python (in 64-bits, not 32 !):

a)苹果规定的方式:作为框架

  • Python.org的正式版本安装在/Library/Frameworks/Python.framework 中,其站点包文件夹位于/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
  • 与Python的科学版思想相同(科学发行版,其中预先安装了许多模块,numpy,scipy,matplotlib等),
  • (您也可以将Homebrew Python版本作为框架安装,请参见下文)
  • the official versions of Python.org are installed in /Library/Frameworks/Python.framework with site-packages folder in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
  • same for the Enthought scientific version of Python (scientific distribution with many modules preinstalled, numpy, scipy, matplotlib,...),
  • (you can also install the Homebrew Python version as a framework, see below)

您必须在/usr/bin 中更改Python可执行文件的PATH(通常,这是通过符号链接分发或在/Users/me/.bash_profile <中自动完成的)/em>文件).

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/;

sudo端口-v安装python27

sudo port -v install python27

Fink在文件夹/sw/;

Fink install its own version of Python in the folder /sw/;

完善安装Python27

fink install Python27

Homebrew通过/usr/local/bin 中的符号链接在/usr/local/Cellar 中安装Python.

Homebrew installs Python in /usr/local/Cellar with symlinks in /usr/local/bin.

简单安装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)自主"方式

  • 完美的解决方案是 Anaconda (另一种预先安装了许多模块的科学发行版),
    • 干净地安装到单个目录(您要作为/Users/me/anaconda 的目录)
    • 不需要root权限
    • 不会影响您系统上的其他Python安装,也不会干扰OS X Frameworks
    • 只需设置$ PATH或在/Users/me/.bash_profile 中创建别名,即可
    • 切换到/从Anaconda
      • alias anaconda ='/Users/me/anaconda/bin/python'
      • alias anaconda3 ='/Users/me/anaconda/envs/py33/bin/python3'
      • the perfect solution is Anaconda (another scientific distribution with many modules preinstalled, ),
        • Installs cleanly into a single directory (where you want as /Users/me/anaconda)
        • doesn’t require root privileges
        • doesn’t affect other Python installs on your system, or interfere with OS X Frameworks
        • switch to/from Anaconda just by setting $PATH or creating an alias in /Users/me/.bash_profile
          • alias anaconda='/Users/me/anaconda/bin/python'
          • alias anaconda3='/Users/me/anaconda/envs/py33/bin/python3'

          d)硬"方式

          • 您可以以经典形式(结果为/usr/)或作为框架来编译自己的Python版本.这需要时间,但并不难.

          所以你的问题:

          如何在虚拟环境中安装Python,该虚拟环境包含可以包含在Xcode中的框架?

          How can I get a Python installation in a virtual environment that includes a framework that I can include into Xcode?

          除非您是Unix专家(PATHs管理),否则必须使用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中的框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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