Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python: import error after making program executable

Tags:

python

When I run the program as python JIRAClient.py, everything works fine. But after I make the program executable by adding #!/usr/bin/env python and giving it execute permission, I get some error when I try to run the program as ./JIRAClient.py

from: can't read /var/mail/jira.client
Version: ImageMagick 6.8.6-3 2013-07-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib freetype jng jpeg png xml zlib

Usage: import [options ...] [ file ]
Image Settings:
......
Image Operators:
......
Miscellaneous Options:
......
By default, 'file' is written in the MIFF image format.  To
specify a particular image format, precede the filename with an image
format name and a colon (i.e. ps:image) or specify the image type as
the filename suffix (i.e. image.ps).  Specify 'file' as '-' for
standard input or output.
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1298.
./JIRAClient.py: line 4: config_ini: command not found
./JIRAClient.py: line 5: syntax error near unexpected token `('
./JIRAClient.py: line 5: `config = ConfigParser.ConfigParser()'

What does this error mean? And what is the difference between these two methods of running the program?

The lines of code that produce error are as following:

from jira.client import JIRA
import ConfigParser

config_ini = 'config.ini'
config = ConfigParser.ConfigParser()
dataset = config.read(config_ini)
like image 910
Cacheing Avatar asked Aug 12 '13 23:08

Cacheing


People also ask

Why is Python running my module when I import it?

This happens because when Python imports a module, it runs all the code in that module. After running the module it takes whatever variables were defined in that module, and it puts them on the module object, which in our case is salutations .


1 Answers

Your program is trying to run like a bash-script, so it seems, your #!/usr/bin/env python had no effect. Make sure that this line is at the top of the program in the first row with no characters before #

like image 159
mingaleg Avatar answered Sep 21 '22 14:09

mingaleg