473,289 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

2 different versions of python compiling files.

I am trying to upgrade from python 2.3 to 2.4 but not all machines can
be upgraded. Can you guys tell me if this scenario is possible.

1. Any machine that uses .py files that use libraries that require 2.4
will have 2.4 on it.
2. rest of the machines will have 2.3

now there is a shared drive. lets say i write a new library called
testlib.py and put it on the shared drive .. when a script uses it
from a 2.4 based machine, it will generate a testlib.pyc and leave it
on the shared drive. going forward that .pyc is used until the
original lib is changed. now lets say a 2.3 based machine is trying to
use that lib. it will try to use that pyc file which was compiled by
py2.4. will it work or crash ?

not sure if i did a good job on explaining my scenario.
Jun 27 '08 #1
4 1478
TkNeo wrote:
I am trying to upgrade from python 2.3 to 2.4 but not all machines can
be upgraded. Can you guys tell me if this scenario is possible.

1. Any machine that uses .py files that use libraries that require 2.4
will have 2.4 on it.
2. rest of the machines will have 2.3

now there is a shared drive. lets say i write a new library called
testlib.py and put it on the shared drive .. when a script uses it
from a 2.4 based machine, it will generate a testlib.pyc and leave it
on the shared drive. going forward that .pyc is used until the
original lib is changed. now lets say a 2.3 based machine is trying to
use that lib. it will try to use that pyc file which was compiled by
py2.4. will it work or crash ?
It should work, as long as the original .py file is still there. Each Python
version will check for a .pyc file *corresponding to that version* (e.g. Python
2.4 will look for a .pyc file compiled with 2.4), and create one if it doesn't
exist, overwriting any existing .pyc file in the process.

If the original .py file is *not* there, it will most likely not work. If you
try to import a .pyc file with the wrong version number, you get something like
this:
>>import foo
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: Bad magic number in foo.pyc

I'm not sure what would happen if multiple Pythons try to write a .pyc file at
the same time, though...

--
Hans Nowak (zephyrfalcon at gmail dot org)
http://4.flowsnake.org/
Jun 27 '08 #2
On May 22, 2:44 pm, Hans Nowak <zephyrfalcon!NO_SP...@gmail.com>
wrote:
TkNeo wrote:
I am trying to upgrade from python 2.3 to 2.4 but not all machines can
be upgraded. Can you guys tell me if this scenario is possible.
1. Any machine that uses .py files that use libraries that require 2.4
will have 2.4 on it.
2. rest of the machines will have 2.3
now there is a shared drive. lets say i write a new library called
testlib.py and put it on the shared drive .. when a script uses it
from a 2.4 based machine, it will generate a testlib.pyc and leave it
on the shared drive. going forward that .pyc is used until the
original lib is changed. now lets say a 2.3 based machine is trying to
use that lib. it will try to use that pyc file which was compiled by
py2.4. will it work or crash ?

It should work, as long as the original .py file is still there. Each Python
version will check for a .pyc file *corresponding to that version* (e.g. Python
2.4 will look for a .pyc file compiled with 2.4), and create one if it doesn't
exist, overwriting any existing .pyc file in the process.

If the original .py file is *not* there, it will most likely not work. If you
try to import a .pyc file with the wrong version number, you get something like
this:
>>import foo
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: Bad magic number in foo.pyc

I'm not sure what would happen if multiple Pythons try to write a .pyc file at
the same time, though...

--
Hans Nowak (zephyrfalcon at gmail dot org)http://4.flowsnake.org/
The original .py will always be there but you know what, multiple
python versions from different computers do access that one library at
the same time.

Anyone know a possible solution ?
Jun 27 '08 #3
On May 22, 3:56 pm, TkNeo <tarun....@gmail.comwrote:
On May 22, 2:44 pm, Hans Nowak <zephyrfalcon!NO_SP...@gmail.com>
wrote:
TkNeo wrote:
I am trying to upgrade from python 2.3 to 2.4 but not all machines can
be upgraded. Can you guys tell me if this scenario is possible.
1. Any machine that uses .py files that use libraries that require 2.4
will have 2.4 on it.
2. rest of the machines will have 2.3
now there is a shared drive. lets say i write a new library called
testlib.py and put it on the shared drive .. when a script uses it
from a 2.4 based machine, it will generate a testlib.pyc and leave it
on the shared drive. going forward that .pyc is used until the
original lib is changed. now lets say a 2.3 based machine is trying to
use that lib. it will try to use that pyc file which was compiled by
py2.4. will it work or crash ?
It should work, as long as the original .py file is still there. Each Python
version will check for a .pyc file *corresponding to that version* (e.g. Python
2.4 will look for a .pyc file compiled with 2.4), and create one if it doesn't
exist, overwriting any existing .pyc file in the process.
If the original .py file is *not* there, it will most likely not work. If you
try to import a .pyc file with the wrong version number, you get something like
this:
>>import foo
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: Bad magic number in foo.pyc
I'm not sure what would happen if multiple Pythons try to write a .pyc file at
the same time, though...
--
Hans Nowak (zephyrfalcon at gmail dot org)http://4.flowsnake.org/

The original .py will always be there but you know what, multiple
python versions from different computers do access that one library at
the same time.

Anyone know a possible solution ?
What error message are you getting?
Jun 27 '08 #4
The original .py will always be there but you know what, multiple python
versions from different computers do access that one library at the same
time.

Anyone know a possible solution ?
What about subversion or mercurial and separate copies of your library
for each Python version?

-- Ivan
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Logan | last post by:
I have two different Python versions on my Linux system (2.2 and 2.3). I cannot remove version 2.2 because many configuration files of the system depend on this version of Python (and its...
9
by: Nuff Said | last post by:
When I type the following code in the interactive python shell, I get 'UTF-8'; but if I put the code into a Python script and run the script - in the same terminal on my Linux box in which I...
29
by: Maurice LING | last post by:
Hi, I remembered reading a MSc thesis about compiling Perl to Java bytecodes (as in java class files). At least, it seems that someone had compiled scheme to java class files quite successfully....
4
by: stuntgoat | last post by:
Hi, I want to start using Python 2.6 and 3000. I have several questions. What, in your experiences, is a functionally elegant solution to installing 2.6 and 3 from source without breaking...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.