LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 08-19-2013, 08:10 AM   #1
dragonpoet
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Rep: Reputation: Disabled
Running Python Scripts


I have Red Hat Enterprise Linux 6.3 installed on two machines. When I try to run a python script on either of them (the same script for testing) it seems to start but immediately end. No pop-ups are present after starting the scripts.

After running the program, it should be asking to change values but it never shows up. Any suggestions on what could be wrong?
 
Old 08-19-2013, 08:18 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Quote:
Originally Posted by dragonpoet View Post
I have Red Hat Enterprise Linux 6.3 installed on two machines. When I try to run a python script on either of them (the same script for testing) it seems to start but immediately end. No pop-ups are present after starting the scripts.

After running the program, it should be asking to change values but it never shows up. Any suggestions on what could be wrong?
A few questions for you:

- How are you running this script? From the GUI or from a terminal or ????
- What command are you using to execute the script?
- Are you sure the script works correctly?
 
Old 08-19-2013, 08:27 AM   #3
dragonpoet
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
A few questions for you:

- How are you running this script? From the GUI or from a terminal or ????
- What command are you using to execute the script?
- Are you sure the script works correctly?
-I've tried just double-clicking and selecting 'run', and I've tried selecting 'run in terminal'
-I've changed the directory to the where the files are and used 'python (file name)'
-I got the script from someone else but on his machine (same OS and build) it ran just fine.

Last edited by dragonpoet; 08-19-2013 at 08:40 AM.
 
Old 08-19-2013, 08:50 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Quote:
Originally Posted by dragonpoet View Post
-I've tried just double-clicking and selecting 'run', and I've tried selecting 'run in terminal'
-I've changed the directory to the where the files are and used 'python (file name)'
-I got the script from someone else but on his machine (same OS and build) it ran just fine.
I'd advise you to use a terminal (or multiple terminals). This makes running/editing the script(s) easier (my opinion).

This should work from a terminal:
Code:
cd /path/to/script_directory
python script_name.py

# mini example

cd /tmp
python test.py
1 + 2 = 3
foo bar foobar

# test.py mini script looks like this
import math
print "1 + 2 =", 1+2
print "foo bar foobar";
You might want to try running the test.py script, just to make sure python is working correctly. If not, please post any error/warning messages that are shown.

If your script isn't too long you might want to post it (do use [code] ... [/code] tags) so we can have a look.
 
Old 08-19-2013, 08:54 AM   #5
dragonpoet
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
I just noticed a message after attempting to run the program in the terminal. "ImportError: no module named argparse"

I tried seeing if I have it using this command | python -c "import argparse; print argparse" and the same message appears.
 
Old 08-19-2013, 09:24 AM   #6
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 167

Rep: Reputation: 35
What version of Python are you running?
 
Old 08-19-2013, 09:26 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Assuming you use python 2.x: The argparse module isn't installed by default and I do believe also not part of the default packages that are available.

A little search comes up with this: python-argparse-1.2.1-2.el6.noarch.rpm

I do believe argparse became part of native python in version 3.2
 
Old 08-19-2013, 09:42 AM   #8
dragonpoet
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
It is version 2.6.6.
 
Old 08-19-2013, 09:46 AM   #9
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 167

Rep: Reputation: 35
Quote:
Originally Posted by dragonpoet View Post
It is version 2.6.6.
Then the module is not installed, you need to install it.
 
Old 08-19-2013, 10:09 AM   #10
dragonpoet
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
I'm attempting to install the version 3.2.5 and when I do the './configure' there is a message saying "no acceptable C compiler in $Path"

I downloaded the file from the website and it was saved to my Downloads folder. I unzipped it and that is when I ran './configure' Is there something I am doing wrong up to this point?

Last edited by dragonpoet; 08-19-2013 at 10:15 AM.
 
Old 08-19-2013, 10:19 AM   #11
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 167

Rep: Reputation: 35
Quote:
Originally Posted by dragonpoet View Post
I'm attempting to install the version 3.2.5 and when I do the './configure' there is a message saying "no acceptable C compiler in $Path"

I downloaded the file from the website and it was saved to my Downloads folder. I unzipped it and that is when I ran './configure' Is there something I am doing wrong up to this point?
Do you have GCC installed? If not, you need to install it.
 
Old 08-19-2013, 10:52 AM   #12
dragonpoet
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Ok. Thanks for all the feedback. I had assumed the GCC would have been installed when I installed the OS. Finally got the GCC installed and finishing installing Python 3.2.5. If I have any other problems I'll be sure to ask for your help again. Thank!
 
Old 08-19-2013, 10:55 AM   #13
szboardstretcher
Senior Member
 
Registered: Aug 2006
Distribution: Arch 2014.02.01
Posts: 2,317
Blog Entries: 1

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
GCC is not installed by default. This is because it is an insecure program to have installed, and is widely used for evil on linux systems. Any compiler can be used for evil on an insecure system. So it is a good idea to use GCC to compile whatever you need, then uninstall it.
 
Old 08-19-2013, 11:15 AM   #14
dragonpoet
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Ok so following the instructions and running the install, it looks as though everything is fine. Then I tried to run my script again and it still says that the argparse module isn't installed. I checked again the version I have for python and I had assumed it would be 3.2.5 but it still says I am on 2.6.6.

I followed the read me instructions that followed like this:

- ./configure
- make
- make test
- yum make install
 
Old 08-19-2013, 11:38 AM   #15
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 167

Rep: Reputation: 35
First, uninstall the older version of Python. Then places the python binary in your PATH.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Python Scripts as a Replacement for Bash Utility Scripts LXer Syndicated Linux News 1 01-17-2013 08:08 AM
[SOLVED] scripts is not running thriugh cron ...manually running fine ghoshdastidar1980 Linux - Newbie 3 09-27-2012 02:42 AM
is suid disabled from running all scripts or just from running them as root monsteriname Programming 2 09-05-2009 02:57 AM
Execute python scripts GameMaker Programming 2 02-09-2006 04:46 AM
compiling Python scripts lex1dr Linux - Software 1 06-16-2003 04:24 PM


All times are GMT -5. The time now is 03:01 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration