LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-15-2007, 04:20 PM   #1
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: West Africa
Distribution: Slackware/Debian (when necessary)
Posts: 2,462
Blog Entries: 1

Rep: Reputation: 126Reputation: 126
how do i compile in ubuntu python?


i have been going through python tutorials but havent come across instructions for compiling. how is it done?
 
Old 02-15-2007, 04:39 PM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware 14.2
Posts: 2,815
Blog Entries: 1

Rep: Reputation: 261Reputation: 261Reputation: 261
If you're using Ubuntu, most everyone is going to recommend using apt-get to install Python. That said,
Code:
./configure --prefix=/usr --enable-shared
make EXTRA_CFLAGS="-fwrapv"
sudo make install
 
Old 02-15-2007, 04:59 PM   #3
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: West Africa
Distribution: Slackware/Debian (when necessary)
Posts: 2,462

Original Poster
Blog Entries: 1

Rep: Reputation: 126Reputation: 126
what is the first part? the terminal doesnt like it
 
Old 02-15-2007, 05:46 PM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Ok, the original question is (to me) ambiguous. What do you mean? Are you asking how to run/execute a python script? Or are you asking how to compile/install a python interpreter?

Answering the first question:
You don't have to "compile" python scripts. They will execute as a text file. You can execute the script in one of two ways:
1. Execute the interpreter (python) at the command line with the script as the first argument. For example:
Code:
username@host$ python script_name.py
OR

2. Make sure you have the path to the interpreter as the first line of the script, and give execute permissions to the script. For example:
Code:
username@host$ which python
/usr/local/bin/python
username@host$ chmod a+x script_name.py
username@host$ ./script_name.py
Contents of script_name.py
Code:
#!/usr/local/bin/python
...
==========================================

If you were originally asking how to install the python interpreter, you need to, again, do one of two things:
1. Install python using apt-get (or the GUI tools to add/remove packages)

OR

2. Compile the python interpreter from source code. This option requires you to download the source code, extract it, and then proceed with a series of commands (very similar, if not identical to what Arow gave) inside the directory containing the source code.

Last edited by Dark_Helmet; 02-15-2007 at 05:47 PM.
 
Old 02-15-2007, 06:01 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,586

Rep: Reputation: 3504Reputation: 3504Reputation: 3504Reputation: 3504Reputation: 3504Reputation: 3504Reputation: 3504Reputation: 3504Reputation: 3504Reputation: 3504Reputation: 3504
I suspect the former - Ubuntu will have installed Python.
Try "python -V" to check.
 
Old 02-16-2007, 01:10 PM   #6
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: West Africa
Distribution: Slackware/Debian (when necessary)
Posts: 2,462

Original Poster
Blog Entries: 1

Rep: Reputation: 126Reputation: 126
the commands Dark_Helmet gave me didnt seem to work. see: http://www.geocities.com/whitehat4u/Screenshot.png

python -V says:

Python 2.4.4c1
 
Old 02-16-2007, 01:11 PM   #7
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: West Africa
Distribution: Slackware/Debian (when necessary)
Posts: 2,462

Original Poster
Blog Entries: 1

Rep: Reputation: 126Reputation: 126
sry-make that http://www.geocities.com/whitehat4u/Screenshot-1.png
 
Old 02-16-2007, 01:14 PM   #8
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
You are getting that error because python cannot find script_name.py in your current working directory.
 
Old 02-16-2007, 01:40 PM   #9
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: West Africa
Distribution: Slackware/Debian (when necessary)
Posts: 2,462

Original Poster
Blog Entries: 1

Rep: Reputation: 126Reputation: 126
which means i need to do what...?
 
Old 02-16-2007, 01:45 PM   #10
rshaw
Senior Member
 
Registered: Apr 2001
Location: Perry, Iowa
Distribution: Mepis , Debian
Posts: 2,692

Rep: Reputation: 45
move script_name.py where it can find it or called the script with the full path name eg. python /home/whatever/script_name.py
 
Old 02-16-2007, 10:28 PM   #11
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Just to be absolutely clear: "script_name.py" is a fake script name. You need to replace it with the filename of the script you're trying to execute. You didn't give the name of the script in your original post, so I just made one up.

If you did save your script as "script_name.py", then do what rshaw suggested:
1. use the cd command to navigate to the directory that has the script in it and execute either "python script_name.py" or "./script_name.py" - the second assumes you have altered the script with the chmod command mentioned earlier

2. give the full path to the script. For instance: "python /home/username/scripts/script_name.py" or "/home/username/scripts/script_name.py" - again, the second assumes the chmod command was used. And, of course, if you try this, substitute the actual path to the script on your computer.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How do u compile python? sduffy89 Programming 3 02-26-2006 10:18 PM
question about compile python-mcrypt bbmak Linux - Software 0 04-14-2005 10:18 PM
trying to compile Python Lung-Dart Linux - Newbie 1 10-27-2004 09:46 AM
compile python progs abs Programming 13 04-05-2004 09:05 PM
compile Python in Linux? pandasuit Programming 2 12-13-2003 05:22 AM

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

All times are GMT -5. The time now is 08:56 AM.

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