execfile and import not working

Peter Otten __peter__ at web.de
Wed Sep 6 07:54:31 EDT 2017


Friedrich Rentsch wrote:

> 
> 
> On 06.09.2017 10:52, Peter Otten wrote:
>> Friedrich Rentsch wrote:
>>
>>> Hi, I am setting up Python 2.7 after an upgrade to Ubuntu 16.04, a
>>> thorough one, leaving no survivors. Everything is fine, IDLE opens,
>>> ready to go. Alas, execfile and import commands don't do my bidding, but
>>> hang IDLE. All I can do is kill the process named "python" from a bash
>>> terminal. IDLE then is still open, says "=== RESTART: Shell ===" and is
>>> again ready for action. It works interactively, but no imports . . .
>>> What could be the problem?
>> Close idle completely (or kill the idle process), then start it from the
>> command line, with an empty PYTHONPATH variable and from an empty
>> directory.
>>
>> $ killall idle
>> idle: no process found
>> $ mkdir empty
>> $ cd empty
>> $ PYTHONPATH= idle
>>
>> Does the problem persist?
>>
> No, it doesn't. It's okay this way. Can you advise me how to set up the
> launcher?

There may be a module in your system path that shades one of the modules 
needed by idle. When you start idle with the GUI the working directory is 
probably your home directory. (If you can import os use os.getcwd() to 
verify) This is just guessing, but the first thing I'd try is to remove all 
Python files from that directory (and also the *.pyc/*.pyo).




More information about the Python-list mailing list