Home › Forums › Installation › Setting PYTHONPATH
- This topic has 4 replies, 2 voices, and was last updated 12 years, 2 months ago by Keith.
-
AuthorPosts
-
September 11, 2012 at 5:00 pm #301KeithKeymaster
Over the years a few people have come unstuck with the need to set the PYTHONPATH environment variable.
Firstly, a little explanation of what it is. PYTHONPATH can be used to set (additional) directories that python modules are searched for. So if you type in the python command line 'import ui' or 'from ui import *' then python looks for a file called 'ui.py' (python source) or 'ui.pyc' (python compiled bytecode) in a search path given by the python variable sys.path.
The same goes for PCells – if you want to put all your PCell .py files in a directory /Users/fred/myPCells, then you'd better add that directory path to your PYTHONPATH, else you will have problems.
Although setting environment variables is easy on Linux, not tricky on Windows, it is a problem on Mac OS X when you start an app by clicking on its icon. This is because any env var you set in your bash shell means nothing to an app started via its icon, as it does not run under a shell.
You can set env vars on OS X, either globally for all apps launched from an icon by setting the env vars in /etc/launchd.conf, or for individual apps in the <app>.app/Contents/Info.plist. If you're not familiar with XCode on the Mac, you will probably not want to try the latter.
So to resolve this, and eliminate setting the PYTHONPATH env var, in 4.3.11 the python sys.path is appended with the location of the ui.py file. Python afficionados can still set sys.path in their scripts, or OS experts can set the env var PYTHONPATH. But for vanilla users nothing should need to be done.
Same goes for GLADE_HOME btw, which was only used to locate the html documentation…
September 20, 2012 at 9:19 am #1216DavidTremParticipantIf it could be of any help:
p, li { white-space: pre-wrap; }
# Glade release version 4.3.11 compiled on Sep 10 2012 14:13:55# Qt version 4.8.2 on 64 bit platform (little endian)# Compiled with gcc version 4.2.1# Username: Hostname:# Current time: Thu Sep 20 11:10:52 2012# Operating system: Darwin 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64# Number of CPUs: 4# OpenGL vendor: Intel Inc.# OpenGL renderer: Intel HD Graphics 3000 OpenGL Engine# OpenGL version: 2.1 APPLE-7.32.12# OpenGL FBOs will be used.# Python version 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] for darwin>>> # WARNING: Failed to import ui module – please check your PYTHONPATH!>>> # WARNING: PYTHONPATH is currently : (null)September 20, 2012 at 10:14 am #1217KeithKeymasterHmm, odd. I'm running OSX 10.8.1, you should see printed in the log just after the Python version something like:
>>> # Adding python module path: /Users/keith/Documents/C++/glade4_mac64.
or it it fails, a message like
>>> # Cound not add python module path: …
Can you try:
import sys
print sys.path?
Also you might want to try re-downloading th mac version in case you got a slightly older version of 4.3.11, it was updated shortly after initially becoming available.
September 20, 2012 at 12:25 pm #1218DavidTremParticipantFixed by reloading latest version
It seems to be
4.3.12 now.
Any way it works !Thanks,
David
p, li { white-space: pre-wrap; }
# Glade release version 4.3.12 compiled on Sep 20 2012 12:44:59# Qt version 4.8.2 on 64 bit platform (little endian)# Compiled with gcc version 4.2.1# Username: Hostname:
# Current time: Thu Sep 20 14:08:05 2012# Operating system: Darwin 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64# Number of CPUs: 4# OpenGL vendor: Intel Inc.# OpenGL renderer: Intel HD Graphics 3000 OpenGL Engine# OpenGL version: 2.1 APPLE-7.32.12# OpenGL FBOs will be used.# Python version 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] for darwin>>> # Adding python module path: /Users/me/Desktop/glade4_mac64September 20, 2012 at 2:14 pm #1219KeithKeymasterThat's good to know.
About changing the version of python – currently Glade expects to link to the Mac python (version 2.7 by default). To use another version of Python, I'd have to install and link to that – which although possible, may be messy on a single machine.
-
AuthorPosts
- You must be logged in to reply to this topic.