473,382 Members | 1,647 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,382 software developers and data experts.

Trouble executing pyc files in ubuntu server

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 6694
varuns
39
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
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
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
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
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
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.