[Tutor] Regarding importing from a sub-directory

Phil phillor9 at gmail.com
Sat Feb 10 15:53:10 EST 2024


On 10/2/24 19:19, Alan Gauld via Tutor wrote:

> Since I took you off moderation a while back I no longer see the
> messages so they all get posted, including this one! :-)
>
> However the IDE is not the answer to the problem since they are
> only used in development. What you need to check is that the
> import works when you run the code directly in Python,
> ie without any IDE.
>
> I suspect the real solution is for you to modify the PYTHONPATH
> or sys.path values to include ~/Python.

This is another of my messages that I wish I could have cancelled.

I found the problem shortly after posting my plea for help and it's 
IDLE. The library is found if I run my project from the command line and 
VS Code has no problem finding the library.

I've had problems with IDLE from time to time in the past not running 
Tkinter code correctly or at all and I think that's due to IDLE itself 
being a Tkinter project. I seldom ever use IDLE but it's the default IDE 
for Python projects (of course I should change that setting) and it's 
handy for a quick edit. In this case it wasn't quick and I spent hours 
chasing a red herring.

By the way, my PYTHONPATH does  include ~/Python and I did experiment 
with setting the sys.path in my project which later turned out be be 
unnecessary anyway.

Thank you again Alan for your time.

-- 

Regards,
Phil


More information about the Tutor mailing list