So, I’ve been working a bit on my password manager (now called Stempel), and it’s working pretty well with CouchDB and a commandline interface, and it’s about time to make a GUI for certain purposes. I’d mentioned before wanting to use PySide for this purpose, and naturally PySide turns out to be one of those things that’s a bit of a pain to install on Mac. Well, if you want to use something besides the system Python, that is, and OF COURSE you want to use something besides the system Python! (Because Mac doesn’t really give you a modern Python…)
I’ve been using pyenv to manage my Python versions, and wouldnchaknow? Once you drop into one of the pyenv shim pythons, Mac can’t find PySide anymore.
Here’s what I did to fix it (and I have NO IDEA whether this is a viable long-term solution for now or not, it’s just what I did and it seems to be working).
The problem, naturally, is that where PySide installs itself is in a system folder. Now, you would think (wouldn’t you?) that you could pip install pyside in your pyenv shim and everything would be peachy. But you’d be wrong … for some reason. pip can’t find qmake to build PySide, and I wasn’t able to find a way to tell pip where qmake is (espcially since I can’t seem to find it myself).
So what I did instead was find the PySide installation and symlink it into my python 2.7.5 shim.
- Find PySide. For me, it turned out to be in /Library/Python/2.7/site-packages/PySide (There’s also /Library/Python/2.7/site-packages/pysideuic, which might or might not be relevant. I symlinked that too.)
- Find your shim site-packages folder. In my case, it was ~/.pyenv/versions/2.7.5/lib/python2.7/site-packages
- cd ~/.pyenv/versions/2.7.5/lib/python2.7/site-packages
- ln -s /Library/Python/2.7/site-packages/PySide PySide
- ln -s /Library/Python/2.7/site-packages/pysideuic pysideuic
Now when I run my test file, even in my pyenv shim, it works! Maybe someday it will break on some advanced features, but for now everything seems to be fine.