Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56517 > unrolled thread
| Started by | Errol Anderson <errol.anderson@gradient.com> |
|---|---|
| First post | 2013-10-09 21:47 +0000 |
| Last post | 2013-10-10 06:04 +0100 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.python
Can anyone help on conflicts between Python 2.5 and 2.7 Errol Anderson <errol.anderson@gradient.com> - 2013-10-09 21:47 +0000
Re: Can anyone help on conflicts between Python 2.5 and 2.7 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-10 01:31 +0000
Re: Can anyone help on conflicts between Python 2.5 and 2.7 Terry Reedy <tjreedy@udel.edu> - 2013-10-09 23:32 -0400
Re: Can anyone help on conflicts between Python 2.5 and 2.7 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-10 06:04 +0100
| From | Errol Anderson <errol.anderson@gradient.com> |
|---|---|
| Date | 2013-10-09 21:47 +0000 |
| Subject | Can anyone help on conflicts between Python 2.5 and 2.7 |
| Message-ID | <mailman.908.1381355287.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
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.
The specific error is identified in Python27\lib\linecache.py line 127
with open(fullname, 'rU') as fp:
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.
Regards
Errol Anderson
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-10-10 01:31 +0000 |
| Message-ID | <52560373$0$29984$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #56517 |
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
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-10-09 23:32 -0400 |
| Message-ID | <mailman.916.1381375942.18130.python-list@python.org> |
| In reply to | #56532 |
On 10/9/2013 9:31 PM, Steven D'Aprano wrote: > 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. It is an option in the installer. > 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 The installers actually tried to put them in C:/python25/python.exe, etc, but lets you choose an install directory other than /. Beyond that, I don't know what going on either. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-10-10 06:04 +0100 |
| Message-ID | <mailman.918.1381381477.18130.python-list@python.org> |
| In reply to | #56532 |
On 10/10/2013 04:32, Terry Reedy wrote: > On 10/9/2013 9:31 PM, Steven D'Aprano wrote: > >> 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. > > It is an option in the installer. > >> 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 > > The installers actually tried to put them in C:/python25/python.exe, > etc, but lets you choose an install directory other than /. > > Beyond that, I don't know what going on either. > Do the Windows gurus know if the launcher described here http://www.python.org/dev/peps/pep-0397/ would help in this instance? -- Roses are red, Violets are blue, Most poems rhyme, But this one doesn't. Mark Lawrence
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web