473,473 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Trouble executing pyc files in ubuntu server

4 New Member
Hi Folks, my first post here. Sorry to start with a request.

I'm having trouble executing python scripts compiled to byte code on ubuntu feisty server version. Basically I can type ./MyScript.py and the script runs fine but if I compile the script and type ./MyScript.pyc it won't run, I just get some junk characters printed to my terminal that mean nothing.

Now if I type python MyScript.pyc it runs fine. I guess it's a path thing, but I'm not too sure how to solve it.

Silly thing is, on my feisty workstation all works as expected.

Anyone have any ideas how I might fix this problem.
Aug 16 '07 #1
7 6701
varuns
39 New Member
Hi Folks, my first post here. Sorry to start with a request.

I'm having trouble executing python scripts compiled to byte code on ubuntu feisty server version. Basically I can type ./MyScript.py and the script runs fine but if I compile the script and type ./MyScript.pyc it won't run, I just get some junk characters printed to my terminal that mean nothing.

Now if I type python MyScript.pyc it runs fine. I guess it's a path thing, but I'm not too sure how to solve it.

Silly thing is, on my feisty workstation all works as expected.

Anyone have any ideas how I might fix this problem.
hi
try changing permission of the .pyc file using
Expand|Select|Wrap|Line Numbers
  1. sudo chmod +x MyScript.pyc
and also first line of the script should be
!#/usr/bin/env python
Aug 16 '07 #2
RawMustard
4 New Member
hi
try changing permission of the .pyc file using
Expand|Select|Wrap|Line Numbers
  1. sudo chmod +x MyScript.pyc
and also first line of the script should be
!#/usr/bin/env python
Hey thanks for the reply.

Yeah I've done all that, the file executes but not correctly for some reason :(
This is stupid, it works perfectly on 3 other machines but not this one. Fresh install and all :( I even tried compiling on another machine where it works and copying it over but still no go :(
Aug 16 '07 #3
varuns
39 New Member
Hey thanks for the reply.

Yeah I've done all that, the file executes but not correctly for some reason :(
This is stupid, it works perfectly on 3 other machines but not this one. Fresh install and all :( I even tried compiling on another machine where it works and copying it over but still no go :(
how r u compiling your script. May be there lies a problem?
I tried this compile.py script

Expand|Select|Wrap|Line Numbers
  1. !#/usr/bin/env python
  2. import py_compile
  3. py_compile.compile("MyScript.py")
and than changed the permission and it worked
Aug 16 '07 #4
RawMustard
4 New Member
how r u compiling your script. May be there lies a problem?
I tried this compile.py script

Expand|Select|Wrap|Line Numbers
  1. !#/usr/bin/env python
  2. import py_compile
  3. py_compile.compile("MyScript.py")
and than changed the permission and it worked
Yeah that how I did it, just from a console though I didn't write a script to do it.

I do $ python
>>> import py_compile
>>> py_compile.compile('libhmi_sys.py')

Then I chmod +x libhmi_sys.pyc

then I try and run it with ./libhmi_sys.pyc

and get:
Expand|Select|Wrap|Line Numbers
  1. root@tilsan1-hmi:/opt/tilsan/hmi# ./libhmi_sys.pyc
  2. : command not foundine 1: 
  3. ./libhmi_sys.pyc: line 2: {+Fc: command not found
  4. ./libhmi_sys.pyc: line 3: dZ
  5.                             Z
  6.                              d: command not found
  7. ./libhmi_sys.pyc: line 4: syntax error near unexpected token `('
  8. ./libhmi_sys.pyc: line 4: `Zd
  9.                               jo;eiie   Zedjoeie       nend
  10. djo1eideendjp eideiie       Zedjoeie       neiie        joeid
  11.                                                       Zeidedjo4djo
  12. ndjo                                                               e
  13.      eqqedjoreideide
  14.                         dZeiie
  15.                                ZedjoAedjo4djo
  16. ndjo                                         e
  17.      eqqedjowedjojeide
  18.                          eide  eideiie       Zedjoeie       neqedjoYeideideiie Zedjoeie       neqqnedS(iNt:iis/opt/tilsan/hmi/tmp/extInput.jss/opt/tilsan/hmi/hmi_db/s /media/TILSAN-USB/4roller-backups     /dev/sdb1cCs
  19.                                                                             tidttidtidttidtittidtdtidtidttd      tidtid'
  20. ^[[?1;2c^[[?1;2croot@tilsan1-hmi:/opt/tilsan/hmi# 1;2c1;2c
  21. bash: 1: command not found
  22. bash: 2c1: command not found
  23. bash: 2c: command not found
  24.  
Does that mean anything to you's guys?

Like I said, on my workstation doing the exact same routine it all works fine :(
Aug 16 '07 #5
varuns
39 New Member
Yeah that how I did it, just from a console though I didn't write a script to do it.

I do $ python
>>> import py_compile
>>> py_compile.compile('libhmi_sys.py')

Then I chmod +x libhmi_sys.pyc

then I try and run it with ./libhmi_sys.pyc

and get:
Expand|Select|Wrap|Line Numbers
  1. root@tilsan1-hmi:/opt/tilsan/hmi# ./libhmi_sys.pyc
  2. : command not foundine 1: 
  3. ./libhmi_sys.pyc: line 2: {+Fc: command not found
  4. ./libhmi_sys.pyc: line 3: dZ
  5.                             Z
  6.                              d: command not found
  7. ./libhmi_sys.pyc: line 4: syntax error near unexpected token `('
  8. ./libhmi_sys.pyc: line 4: `Zd
  9.                               jo;eiie   Zedjoeie       nend
  10. djo1eideendjp eideiie       Zedjoeie       neiie        joeid
  11.                                                       Zeidedjo4djo
  12. ndjo                                                               e
  13.      eqqedjoreideide
  14.                         dZeiie
  15.                                ZedjoAedjo4djo
  16. ndjo                                         e
  17.      eqqedjowedjojeide
  18.                          eide  eideiie       Zedjoeie       neqedjoYeideideiie Zedjoeie       neqqnedS(iNt:iis/opt/tilsan/hmi/tmp/extInput.jss/opt/tilsan/hmi/hmi_db/s /media/TILSAN-USB/4roller-backups     /dev/sdb1cCs
  19.                                                                             tidttidtidttidtittidtdtidtidttd      tidtid'
  20. ^[[?1;2c^[[?1;2croot@tilsan1-hmi:/opt/tilsan/hmi# 1;2c1;2c
  21. bash: 1: command not found
  22. bash: 2c1: command not found
  23. bash: 2c: command not found
  24.  
Does that mean anything to you's guys?

Like I said, on my workstation doing the exact same routine it all works fine :(
this is really weired, i have no idea about this, may be someone will post a solution or you can post the solution before anyone does.
Aug 17 '07 #6
RawMustard
4 New Member
Yep seems no one know what's going on. I suspect ubuntu server version of python is borked. It works on any of their other releases, live cd, desktop xubuntu, just doesn't work on their server version.

It's actually not compiling the scripts properly for some reason, because if I compile a script on the server and move the pyc file to my workstation it won't run, yet compiling the same script on my workstation works fine on my workstation but won't run on the server.
Aug 18 '07 #7
foo123
1 New Member
This is because you need to install the binfmt-support package - from the package description, it "allows system administrators to register interpreters for
various binary formats based on a magic number or their file extension, and
cause the appropriate interpreter to be invoked whenever a matching file is
executed".

I had this python problem too, and this fixed it for me :-)
Nov 11 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Phil | last post by:
Hi, I have my create statments for tables, procedures, views, etc in individual Transact-SQL script files (.sql). I wnat to write another script file that executes these scripts in the...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
9
by: Don | last post by:
I'm trying to run the following page on my desktop from my host server. It works just fine if I run it from my desktop, but not if I run it from the server. I get "Error: Permission denied" on...
5
by: bg_ie | last post by:
Hi all, I'm trying to use the following kit - http://ccrma.stanford.edu/software/stk/ but I'm having trouble building the code. I've tried isolating the problem by deleting code and...
1
TMS
by: TMS | last post by:
I'm trying to write an address book that is based on a binary tree. I'm devloping in Visual C++ (I blew up my Ubuntu with the new dist, so no EMACS), starting with the basics: #ifndef...
11
by: dave6502 | last post by:
Newbe C++ programmer. I am trying to bug fix a simple KDE application that uses C++. There is a main directory with .cpp & .h files in it. I need to write some additional code and split it up...
4
by: per9000 | last post by:
Hi python people, I am trying to figure out the best way to encrypt files in python. I've build a small script (see below) that encrypts the ubuntu 7.04 iso file in 2 minutes (I like python :)...
2
by: eduardoamfm | last post by:
Hi everybody! I have the following files: (MSC.080806.00, MSC.080806.01, MSC.080806.02...) each one has the same pattern, with two different START and STOP times and values: ... ...
10
tpgames
by: tpgames | last post by:
I just inherited a desktop with ubuntu installed and a bunch of other cool apps. The issue is that the person who gave me the computer accidentally deleted the folder that update manager uses to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.