LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-01-2006, 08:10 AM   #1
deep_jyotsingh
LQ Newbie
 
Registered: Mar 2006
Location: New Delhi India
Distribution: Suse
Posts: 22

Rep: Reputation: 15
python executable


can anyone tell me how do i get to make a bin or .pyc extension file with my python code.i need to make my code executable so that no can see my code.
 
Old 06-01-2006, 02:33 PM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
Whenever you import a .py module, python will compile it into a .pyc file.
 
Old 06-02-2006, 02:12 AM   #3
deep_jyotsingh
LQ Newbie
 
Registered: Mar 2006
Location: New Delhi India
Distribution: Suse
Posts: 22

Original Poster
Rep: Reputation: 15
thanks for reply

hi i did the same thing but i get following error i dont whats wrong

python
Python 2.4.2 (#1, Feb 12 2006, 03:59:46)
[GCC 4.1.0 20060210 (Red Hat 4.1.0-0.24)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hello.py
This is a multi-line string. This is the first line.
This is the second line.
"What's your name?," I asked.
He said "Bond, James Bond."

Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named py


my script is
#!/usr/bin/python
#Filename : hello.py
print '''This is a multi-line string. This is the first line.
This is the second line.
"What's your name?," I asked.
He said "Bond, James Bond."
'''
s='hi this is.\
deep jyot singh.'
print \
s
number = 45
guess = int(raw_input('Enter an Integer : '))
if guess == number:
print 'Congratulations,you guessed it correct.'
elif guess < number:
print 'you are higher than number'
else:
print 'your guess is wrong'
print 'Done'
 
Old 06-02-2006, 04:09 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Remove ".py" when importing. Like this:
Code:
import hello
Alternatively, you can usea python script like this:
Code:
#!/usr/bin/env python

from compileall import *
compile_dir('.', 0, force=True)
This will compile all *.py files in the current working directory.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing Conflict: python-devel conflicts python< 2.3.4-13.1 guarriman Fedora 2 04-23-2009 07:02 PM
python problem - compiled from source - python -V still showing old version txm123 Linux - Newbie 1 02-15-2006 11:05 AM
Running a Java executable class from another executable class LUB997 Programming 22 07-24-2005 04:57 AM
WineX, python-gnome, and python-gtk DrD Fedora 0 08-03-2004 12:11 PM
install python 2.3 ,necssary to remove python 2.2 ngan_yine Linux - Newbie 7 12-28-2003 04:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration