LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how do i compile in ubuntu python? (https://www.linuxquestions.org/questions/programming-9/how-do-i-compile-in-ubuntu-python-529427/)

phantom_cyph 02-15-2007 04:20 PM

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?

weibullguy 02-15-2007 04:39 PM

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


phantom_cyph 02-15-2007 04:59 PM

what is the first part? the terminal doesnt like it

Dark_Helmet 02-15-2007 05:46 PM

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.

syg00 02-15-2007 06:01 PM

I suspect the former - Ubuntu will have installed Python.
Try "python -V" to check.

phantom_cyph 02-16-2007 01:10 PM

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

phantom_cyph 02-16-2007 01:11 PM

sry-make that http://www.geocities.com/whitehat4u/Screenshot-1.png

reddazz 02-16-2007 01:14 PM

You are getting that error because python cannot find script_name.py in your current working directory.

phantom_cyph 02-16-2007 01:40 PM

which means i need to do what...?

rshaw 02-16-2007 01:45 PM

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

Dark_Helmet 02-16-2007 10:28 PM

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.


All times are GMT -5. The time now is 10:58 PM.