Programming :: Make Python Programs Run Without Entering The Command Python?
Mar 22, 2009I want to be able to do
sudo ./program.py
instead of always having to do
sudo python program.py
What do I need to change?
I want to be able to do
sudo ./program.py
instead of always having to do
sudo python program.py
What do I need to change?
I've already used line split stuff to transform my data into something like this in a text file:
Code:
['1', '1', '3', '20.7505207']
['2', '1', '3', '23.0488319']
['3', '1', '3', '-1.5768747']
['4', '1', '3', '-26.4772491']
[code]....
How can I get this on a python program so I can manipulate it as an array?
I have list of programs which I have created during the past few days, all the programs are attached in txt files, and if anyone can do favor, and double check if they work, and what changes I can make to make it look different, or to improve it.
View 9 Replies View RelatedI have a function definition in a Python 2.x script which take a tuple as one of its arguments, but 2to3 has no answers nor any of my searching on how to represent the same in Python 3.x
Code:
def blah(self, (string1, string2))
I need to execute an external command with Python from Web. I know there is subprocess module that executes external programs but I'm trying to execute a command registered for the execution of a program. In this case when I execute my file in the shell everything is Ok, but from the Web it doesn't work.
View 1 Replies View RelatedI've writte a small Munin plugin using python, which basically runs a shell command, and write the output to a file. For some reason the script fail quite often, and it seems to be failing at the "commands.getoutput" statement. This is what's leading up to that statement:
[Code]..
If i have a python file with a function call_me(a,b),how can I call this function from the command line ,after i compile the program?
View 5 Replies View Relatedin ubuntu 10.10, I have installed python 2.7. I would like to use apt-get to install packages to this version of python but I haven't been able to figure out howThings I have tried without success:changing the symlink at /usr/bin/python to point to /usr/bin/python2.7 - even after doing this apt-get still installs stuff to python2.6.Set up python2.7 as the primary alternative using update-alternatives - doesn't work
View 3 Replies View RelatedPython 3 want situation for python 2?Python 2 become stop?
View 1 Replies View Relatedyum dependency problem please? I am running Centos 5.5. I need to install python-devel, but when I do so I get:
[Code]....
I've been using Ubuntu 9.10 fairly regularly on my home computer for a week or two now, dual-booting it with Windows 7. So far I've been quite happy with it, but yesterday something odd happened. I decided to copy all the music I had stored on the Windows partition over to the Ubuntu file system so that I could listen to it there. I have about 16 gigs of music mostly in .mp3 format, so I put the folder on an external hard drive, then logged into Ubuntu and copied it back from the external drive to my Music file.
Once the transfer was done, I opened the Music file and double-clicked on one of the .mp3s at random to play it. When I did this, a window popped up and the first half-second or so of the track played, and then the window closed and it stopped. This happened once or twice more with different .mp3s. The window didn't last long enough for me to get a good idea of what program it was for, but I assume it was Totem, which I hadn't yet run since installing Ubuntu, because according to the Properties->Open With tab of any .mp3 file, that's the default program to use to open .mp3s.
Attempting to run Totem from the Applications menu gives the same result, I later found. Attempting to run Totem from a terminal gave the following error:
andrew@Lovelace-Linux:~$ totem
** (totem:2323): WARNING **: Could not import pygtk
ImportError: No module named pygtk
Segmentation fault
Then, several other programs began having similar issues immediately after I first tried to play a .mp3 yesterday. Specifically, Rhythmbox - which I also hadn't used before, and next tried to use to play the music - will not start at all. Running it from the terminal gives:
andrew@Lovelace-Linux:~$ rhythmbox
** (rhythmbox:2338): CRITICAL **: atk_object_set_name: assertion `name != NULL' failed
** (rhythmbox:2338): CRITICAL **: atk_object_set_name: assertion `name != NULL' failed
(rhythmbox:2338): Rhythmbox-WARNING **: Could not import pygtk
ImportError: No module named pygtk
Segmentation fault
Note that pygtk is again referenced. The weirdest part is that other program that's having this issue, an IM client called emesene, is one that I had been using just fine, without issue, for several sessions previous. Since trying to play that .mp3, it now won't run at all. I tried removing and re-installing emesene, to no avail. Running it from the Terminal gives:
andrew@Lovelace-Linux:~$ emesene
Traceback (most recent call last):
File "/usr/share/emesene/Controller.py", line 21, in <module>
import gtk
ImportError: No module named gtk
This time the missing module is gtk, but I know that emesene is written in Python, which the earlier "pygtk" is perhaps a reference to. Thus, the connecting thread between all these programs, as near as I can tell, is Python.
since it started i cannot launch software-center, vlc, emesene... they all stopped working... i checked the logs of synaptic to see if i removed a python package and i didn't. i tried selecting all python packages for reinstall, and it didn't help! i really don't want to reinstall ubuntu.
View 9 Replies View RelatedI wanted to save a python program because I am reading byte of python and I went to save in !/usr/bin. When I try to save in this folder I get this error "[Errno 13] Permission denied: 'usr/bin/helloworld.py'.
View 9 Replies View RelatedHow can I upgrade python-2.4.3 to python-2.5?
View 1 Replies View RelatedI need to know how to make a program use a version of python older than the newest one. I am trying to run the Traipse fork of OpenRPG. Through their forums, I have learned that one of my problems is that I am running too new a version of python. I have python 2.7.1 installed.
I also have python2.6.6 installed, so I should be able to use that. My first thought was to uninstall 2.7.1 and just use the older version. The problem is that if i uninstall 2.7.1, it wants to also uninstall all the packages dependent on that program. Let's face it, in Natty Narwhal, that is pretty much everything.
Do you know how to force Traipse make it use the 2.6 version?
I'm starting to learn python and I am wondering whether I should start with python 2.x or should I just start learning python 3.x?
View 2 Replies View Relatedi have ubuntu 10.04 and python 2.6 installed how do i run, stop or restart a .py file from the command line.
btw im using Putty from a windows computer
I want that I click with the mouse on the video, it paused.I notice that there is "BaconVideoWidget" which I guess is the video rendering widget but it don't have signal named "clicked":
Code:
vd = totem_object.get_video_widget()
vd.connect("clicked", vd.hide)
[code]....
I have an existing line of code from a P2 script that I cannot find a solution to converting to P3:
Code:
for i, x in map(None, list1, list2):
I have found the information about converting the simple case:
map(None,x) becomes list(x)
But my googling was unable to find a solution when more than one iterable exists.
I have a python script I wrote a while ago and now I would like to call that script from inside C. I know how to do one command from C, but how would you execute an entire script from C, and passing arguments? Like:
Code:
int main(void)
{
python( myprogram(1 2 3) );
}
So I can pass arguments to my script.
what the equivalent function in Python 3.1.1 is for Python 2.6.4s:
Py_FindMethod
Be buggered if I can find anything in the doco to say what replaced it or what alternative code may need to be entered to replace it
I have decided to learn python as it seems to be powerful not just for web development (like php) but also a clean powerful language for other puposes.
Q: Can someone suggest a tutorial or book, on learning python (beginner to intermediate) which has as its focus for learning, web development?
In order of preference: 1. Comprehensive, 2. Online, 3. Free
How do I kill a python application from the command line? For an example I have 2 applications running. The first is bleachbit and the second is furiusisomount. They are both python applications so they both come up as python under process name. I could kill them by ID number but if there was another way to do it so that it could be automated in a bash script.
View 9 Replies View RelatedI had problems with python stuff and so update manager did not work. Also many other problems, PiTiVi was installed but did not start eg... After many trials of this and that I removed python-gtk2 and so also ubuntu desktop. But was unable to get it back. Now I cannot even shut down. While it is not possible to install desktop or anything else, would it be possible to fix this by upgrading the whole system to 10.04 (10.10?)? Would it fix python installation. How could I do it. Some info tells to change sources.list and run apt-get upgrade, but some tell not to do so.
t@t:~$ update-manager
Traceback (most recent call last):
File "/usr/bin/update-manager", line 26, in <module>
[code]....
Fedora 12 officially uses Python 2.6, good. But the Google AppEngine still goes by Python 2.5 and is showing import errors while i try to start the SDK. Here is the stack trace.
[URL]
I have a bash script that I want to import in to Python, mainly just to see if I can or not. However in the script I do use some piping of commands into sed to trim it down to what I need. When I tried doing it with the os.system() call, it didn't work. The exact error is
sed: -e expression #1, char 16: unterminated `s' command
However the command that was run can be run in bash without an error. Is there a better/another way to do this? For reference the command is:
Code:
locate -n 1 wp-config.php | sed 's/wp-config.php/
/g' | sed '/wp-config.php/ d' | sed '/^$/ d'
I am using Centos. I have written some scipts in python that access my routers and fetch the configuration, etc. Now i was thinking of creating a web interface which i can access from my windows XP. I want it to have good look n feel :-),
View 7 Replies View RelatedI want to create 3D animation and also make some big programs. Is python capable of that? or should I stick to C++?
View 3 Replies View RelatedI am trying to build an application that must link with python so as to load a python module during runtime.I have this makefile :
Code:
[alex@iskandhar src]$ cat Makefile
CFLAGS = -Wall -O3 -I ../../../SPOOLES.2.2 -DARCH="Linux" -DSPOOLES -DARPACK
[code]....
I have a list of list and I'd like to sort the list according to the last value of each row.
Let's say we have the list
L1 = [ [1,2] , [4,6] , [78,-3] ]
I wish to get
L2 = [ [78,-3] , [1,2] , [4,6] ]
Is there a simple way to do that in python?