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?
|
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 |
what is the first part? the terminal doesnt like it
|
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 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 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. |
I suspect the former - Ubuntu will have installed Python.
Try "python -V" to check. |
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 |
sry-make that http://www.geocities.com/whitehat4u/Screenshot-1.png
|
You are getting that error because python cannot find script_name.py in your current working directory.
|
which means i need to do what...?
|
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
|
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. |