Hi Errol, Happy to help, but first I have a brief note about house-keeping... this group is both a mailing list and a newsgroup on Usenet. A text newsgroup, so I'm afraid that HTML posts are frowned upon, because a large number of people reading this will see your message something like this:
> <html xmlns:v="urn:schemas-microsoft-com:vml" > xmlns:o="urn:schemas-microsoft-com:office:office" > xmlns:w="urn:schemas-microsoft-com:office:word" > xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" > xmlns="http://www.w3.org/TR/REC-html40"> <head> > <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> > <meta name="Generator" content="Microsoft Word 14 (filtered medium)"> > <style><!-- > /* Font Definitions */ > @font-face > {font-family:Calibri; > panose-1:2 15 5 2 2 2 4 3 2 4;} and so on, for about a page or two. Pretty awful, hey? [Aside: if you must generate HTML email, please don't use Word to do so, because it generates absolutely *rubbish* HTML.] So, if you wouldn't mind, could you please turn off "Rich Text" in your messages here? Thanks in advance. Now on to your question... my responses are interleaved with your comments. On Wed, 09 Oct 2013 21:47:54 +0000, Errol Anderson wrote: > I maintain a Delphi program, AAA, that runs Python 2.5 scripts using the > PythonForDelphi (P4D)interface. I can install both Python 2.5 and > Python 2.7 on my computer and AAA is unaffected. However one user of > AAA uses another program, BBB, that requires Python 2.7. When they run > AAA, an error is generated that suggests that AAA has been directed to > the Python 2.7 libraries. I gather that you're running Windows. Is that correct? > The specific error is identified in Python27\lib\linecache.py line 127 > with open(fullname, 'rU') as fp: Yes, but what actually is the error? Please copy and paste the entire traceback, starting with the line: Traceback (most recent call last) My guess is that your user is getting a SyntaxError, but I could be wrong. If you're getting SyntaxError, that suggests that the Python2.5 executable is looking in the 2.7 directory. > as compared with Python25\lib\linecache.py line 128 > fp = open(fullname, 'rU') > > It appears that the BBB program installs Python 2.7 to be the "default" > Python version, although I do not know how this is done. Assuming BBB > cannot be changed, I would like to know how I can modify AAA so that it > ignores any "default" settings and simply runs Python 2.5. I'm not a Windows guru, so I might be off-mark here (I'm sure somebody will correct me) but as I understand it, the "default Python" under Windows is the one that was installed most recently. So, assuming you have Python2.5 installed in Python25 and Python 2.7 in Python27, I would expect that you also have the actual executables in: C:\Program Files\python25.exe C:\Program Files\python27.exe and then .py files will be associated with whichever was installed last. I don't think this is the problem though. If it were, your user would be trying to run AAA with Python 2.7, and likely getting a completely different error. Can you get your user to run these few lines of Python code using whatever technique they use to run AAA? E.g. if they run AAA by double- clicking on an icon, you may need to create an icon that does the same thing but substitutes this script for AAA. import os, sys print sys.version print sys.path print os.getenv('PYTHONPATH', '-none-') print os.getenv('PYTHONSTARTUP', '-none-') This will identify the version of the Python executable running, the search path it uses for libraries, and the value of two environment variables which could be used to change the search path. If you post the result of this, that will help diagnose the problem. At worst, a dirty way of fixing this problem would be for program AAA to manually inspect sys.path, removing any components that look like they've come from Python2.7, and (if necessary) re-inserting any that come from Python2.5. But really, that sort of thing should be unnecessary. -- Steven -- https://mail.python.org/mailman/listinfo/python-list