0

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!

Community
  • 1
  • 1
chadmaughan
  • 578
  • 1
  • 4
  • 12

2 Answers2

1

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 the defaults command to permanently set 32-mode (as documented in Apple's man python):

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

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:

sudo lipo /usr/bin/python2.7 -extract_family i386 -output /usr/local/bin/python2.7-32
sudo chmod 755 /usr/local/bin/python2.7-32

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.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151
  • Thanks Ned. I tried that but no luck, it apparently doesn't reference those settings (or environment variables either). PS - one of your previous answers helped me get cx_Oracle up and running in the terminal. Thanks! – chadmaughan Dec 10 '11 at 04:51
  • Sorry! See the updated answer for some other suggestions. Good luck! – Ned Deily Dec 10 '11 at 05:29
0

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.