This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: hardcoded python paths
Type: Stage:
Components: IDLE Versions: Python 2.3
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: jackjansen Nosy List: jackjansen, kbk, tiagoh
Priority: normal Keywords:

Created on 2003-07-09 11:39 by tiagoh, last changed 2022-04-10 16:09 by admin. This issue is now closed.

Messages (3)
msg16979 - (view) Author: Tiago Castro Henriques (tiagoh) Date: 2003-07-09 11:39
I tried to use the new version of idle that is now
integrated into 2.3b2, but I got an error when I tried
to run /usr/local/lib/python2.3/idlelib/idle:

% /usr/local/lib/python2.3/idlelib/idle
Traceback (most recent call last):
  File "./idle", line 8, in ?
    import PyShell
  File "./PyShell.py", line 19, in ?
    from Tkinter import *
  File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 35,
in ?
    import _tkinter # If this fails your Python may not
be configured for Tk
ImportError: No module named _tkinter

I'm using python2.3b2 on MacOSX 10.2.6, compiled from
source with standard options.

Apparently the builtin 2.2 version of Python is being
used, even though $PYTHONHOME is not set (according to
the manpages, this should make it default to
/usr/local, and not /usr as seems to be the case).

This is due to the fact that this executable script
contains a shebang declaration with a hardcoded python
path:

% head -1 /usr/local/lib/python2.3/idlelib/idle
#!/usr/bin/python

This should be replaced by the standard shebang
declaration:
#! /usr/bin/env python

I checked to see if there were any other *.py files in
/usr/local/lib/python2.3 suffering from similar
problems, and found the following files to be affected:

/usr/local/lib/python2.3/cgi.py:
#! /usr/local/bin/python
/usr/local/lib/python2.3/test/test_bz2.py:
#!/usr/bin/python
/usr/local/lib/python2.3/test/test_largefile.py:
#!python
/usr/local/lib/python2.3/test/test_optparse.py:
#!/usr/bin/python

The files /usr/local/bin/idle, /usr/local/bin/pydoc and
/usr/local/bin/pycolor also have a hardcoded python path:
% head -1 idle pycolor pydoc
==> idle <==
#!/usr/local/bin/python

==> pycolor <==
#!/usr/local/bin/python

==> pydoc <==
#!/usr/local/bin/python

These should similarly be changed to #! /usr/bin/env python
msg16980 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2003-09-10 03:11
Logged In: YES 
user_id=149084

Refer to Python Bug 775061 (closed)

idlelib/idle  script has been removed since the
idle script is now in Tools/scripts and at least
the Linux installation is setting the shebang correctly.

Also, the shebang has been removed from idlelib/idle.py.

I don't know how OSX handles the script installation
so I'm referring this to Jack Jansen in case there is
a further problem.  How does IDLE start on OSX 
these days?  Is there any problem backporting the
deletions to 2.3 maint?
msg16981 - (view) Author: Jack Jansen (jackjansen) * (Python committer) Date: 2004-07-16 14:48
Logged In: YES 
user_id=45365

Idle on MacOSX isn't run from the commandline: you doubleclick the icon 
in the finder. And what gets launched then is an applet, which doesn't 
look at #! paths or anything.

If you want to run idle from the command line you could do that, but you 
would have to use #!/usr/bin/pythonw, not #!/usr/bin/python.
History
Date User Action Args
2022-04-10 16:09:53adminsetgithub: 38824
2003-07-09 11:39:45tiagohcreate