简体   繁体   中英

Correctly Installing and configuring Python/Pyside/PyDev on OS X Lion (and likely future versions of OS X)

I am having issues with PyDev not auto completing pyside correctly, I suspect that I am missing a crucial step in the installation process.

So, How does one install and configure a fresh OS X lion install to develop pyside ?

Note: This Question does NOT belong on another stack site. This is what a programmer has to do to get his machine in shape to develop python PySide using PyDev. A system administrator is unlikely to have encountered this specific issue.

I suspect you followed the various scattered documentation around and mixed different python interpreters and python tools. Also Step 4 below needs to also be done, which not many guides mention.

To get the system in a state for PySide development in line with a linux distro, where all the plumbing aligns by default you have to do the following steps:

Step 1 : install Xcode, brew, and xcode command line tools (you will find documentation for this on the brew website). Once you have Xcode and command line tools downloaded and installed the following command line should install brew.

/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

Check everything is OK with brew doctor .

add the path for user installed binaries to ~/.profile or /etc/paths with a text editor ( export PATH=/usr/local/bin:$PATH ). Make sure the new path is before the $PATH (or at the top of /etc/paths and not after).

Also, after install you want to make sure any python admin utilities that you use are picked up from the correct directory. For this add /usr/local/share/python to the path next to the new path you specified above. This is important because you want easy_install to be correctly functioning and installing to your version of python and not sox's, below we verify that the correct items are being picked up.

Step 2: Use brew to install python2.7.*

brew install readline sqlite gdbm pkg-config
brew install python --framework --universal

Step 3: verify the python binary and the easy_install binary are in the correct directories. You do this by using which and not whereis .

Step 4: Since OSX has the funky notion of frameworks, for library management, we have to symlink things so that other tools (such as eclipse) can auto config correctly.

cd /Library/Frameworks/Python.framework/Versions
sudo rm Current
sudo ln -s /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/Current
# following might not be needed or advised (see discussion below).
cd /System/Library/Frameworks/Python.framework/Versions
sudo rm Current
sudo ln -s /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/Current

Step 5: Install pyside using brew ( brew install pydev ). This also installs Qt4 as a dependency.

Step 6: Install Eclipse along with PyDev

Step 7: Configure eclipse. Do not auto configure, manually add a new interpreter and supply /usr/local/bin/python as the python path. It should pick up the libraries automatically. Also add PySide to the built-ins, since PySide autocompletion requires active introspection, rather than static code analysis.

Step 8: install pip easy_install install pip

Provided you use pip or brew for getting further python code, you should get things piping into the correct directories. That is till mountain lion comes along and ruins your day :D

note to self

I Know now that dependency management is no easier in python compared to windows .net or C/C++ (CRT) GAC or Linux's soname's or java's class path. We all end of with a maze of indirections.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM