强制 PyCharm (1.5.4) 配置解释器使用 32 位 OSX Lion Python 发行版 (2.7.1)
我知道如何在 OSX Lion 上以 32 位模式启动 PyCharm,但如何在 PyCharm 中配置解释器以使用 Apple 提供的 Python 版本(当前为 2.7.1)的 32 位版本?
从终端启动时我成功地使其工作,但 PyCharm 似乎不会读取这些系统变量或默认值。
我正在尝试让 cx_Oracle 使用 PyCharm 中的一些脚本。请参阅以下问题了解更多详细信息:
无法让 cx_Oracle 使用 Python 版本 2.7 / mac os 10.7.2 (Lion) - Missing_OCIAttrGet
提前感谢您的回复!
I know how to start PyCharm in 32-bit mode on OSX Lion, but how do I get the interpreter configured in PyCharm to use the 32-bit version of the Apple shipped Python version (currently 2.7.1)?
I successfully have it working when launched from the terminal, but it appears that PyCharm doesn't read those system variables or defaults.
I'm trying to get cx_Oracle working with some scripts in PyCharm. Please see the following question for more details:
Can't get cx_Oracle to work with Python version 2.7 / mac os 10.7.2 (Lion) - missing_OCIAttrGet
Thanks in advance for your response!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不使用 PyCharm,所以我无法对此进行测试,但看来您可以配置 Python 解释器的非标准路径(请参阅 PYCharm 帮助 此处)。如果是这样,请尝试使用
/usr/bin/python
作为路径。如果您使用defaults
命令永久设置 32 模式(如 Apple 的man python
中所述):这应该可以解决问题。设置环境变量可能不起作用。
更新:既然你报告说这不起作用,那么还有另一种更严重的可能性。您可以使用 lipo 命令从多架构(通用)二进制文件中提取 32 位架构二进制文件。尝试这样的操作:
然后将 PyCharm 中的解释器路径设置为该文件。这很丑陋,因为您需要密切关注 Apple 的任何 Python 更新并重复该过程。如果 PyCharm 直接从框架执行 Python 可执行文件,则这可能不起作用。如果无法获得 PyCharm 的支持或解决 Oracle 问题,万无一失的解决方案是安装仅 32 位版本的 Python。来自 python.org 的预构建的仅 32 位安装程序对于 Lion 10.7 来说是有问题的,因为它们依赖于 gcc-4.0 和 10.4u SDK,而 Xcode 4 中不再提供这两者。但是,您可以自己构建它,或者,经过一点配置,您应该能够让 MacPorts 构建一个。
I don't use PyCharm so I can't test this but it appears you can configure a non-standard path to the Python interpreter (see PYCharm help here). If so, try using
/usr/bin/python
as the path. If you've used thedefaults
command to permanently set 32-mode (as documented in Apple'sman python
):that should do the trick. Setting the environment variable probably won't work.
UPDATE: Since you report that that does not work, here's another, more drastic possibility. You can extract the 32-bit architecture binary from the multi-architecture (universal) binary by using the
lipo
command. Try something like this:Then set the interpreter path in PyCharm to that file. It's ugly because you will need to keep an eye on any Python updates from Apple and repeat the process. If PyCharm is exec-ing the Python executable directly from the framework, then this may not work. Short of getting some support in PyCharm or resolving the Oracle issue, the fool-proof solution would be to install a 32-bit-only version of Python. The pre-built 32-bit-only installers from python.org are problematic for Lion 10.7 because of their dependence on gcc-4.0 and the 10.4u SDK, both no longer provided in Xcode 4. However, you could build it yourself or, with a little bit of configuring, you should be able to get MacPorts to build one.
由于某种原因,这些都不适合我。有点蹩脚的是 pycharm 不支持这个..
我最终将 BASH 支持插件添加到 PyCharm: Preferences >插件>浏览存储库> BashSupport
然后我将一个新的 bash 文件添加到我的项目中,内容如下:
#!/bin/bash
arch -i386 /usr/bin/python ./<与此处位于同一目录中的脚本名称>
通过右键单击并运行来运行它。现在它会出现在您的“配置”下拉列表中。
现在您可以将脚本作为 32 位 python 运行,查看标准输出,并编辑 .py 文件。
For some reason none of that worked for me. Kind of lame that pycharm doesn't support this..
I ended up adding the BASH support plugin to PyCharm: Preferences > Plugins > Browse Repository > BashSupport
Then I add a new bash file to my project with the content:
#!/bin/bash
arch -i386 /usr/bin/python ./<your script name that's in the same directory here>
Run it by right clicking and running. Now it'll appear in your 'configurations' drop down.
Now you can run the script as 32-bit python, see the standard out, and edit the .py file.