Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UMR not reloading modules, when imported as entire .py file #20469

Open
8 of 10 tasks
Jesperten opened this issue Feb 3, 2023 · 3 comments
Open
8 of 10 tasks

UMR not reloading modules, when imported as entire .py file #20469

Jesperten opened this issue Feb 3, 2023 · 3 comments

Comments

@Jesperten
Copy link

Jesperten commented Feb 3, 2023

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

I am experiencing that Spyder UMR does not reload modules, when import these modules as an entire .py file.

So, for instance, in my project, I have a folder called "Modules".
In this folder I have several .py files, which I use as different modules in my project.

If I import a specific function (my_func) within a module (my_module.py file located in the Modules folder), using:

from Modules.my_module import my_func
The UMR manages to reload the my_module every time.

If I just import the module directly using:

from Modules import my_module
The UMR does not reload the my_module module

These modules typically contain more than one function, so it convenient for me to import an entire module instead of importing the specific functions within the module.

Is there a way to fix this, or do I have to import the functions individually, to get the UMR function to work as intended?

What steps reproduce the problem?

  1. from Modules import my_module
  2. run whatever script that is using my_module

What is the expected output? What do you see instead?

I expected that my_module is being reloaded every time I run the script, which then uses my_module.my_func() at some point.
But this is only the case, when I import the function specifically as
from Modules.my_module import my_func

Versions

  • Spyder version: 5.3.3
  • Python version: 3.10.9
  • Qt version: 5.15.2
  • PyQt version: 5.15.7
  • Operating System name/version: Windows 10
@hbengtsson
Copy link

Hi,

I have this exact same problem using the new Spyder version:

  • Spyder version: 6.0.2 (standalone)
  • Python version: 3.11.10 64-bit
  • Qt version: 5.15.8
  • PyQt5 version: 5.15.9
  • Operating System: Windows-10-10.0.22631-SP0

Any fixes or updates on the matter?

Kind regards,
Hjalte

@dalthviz
Copy link
Member

Hi @Jesperten and @hbengtsson sorry for such a late response! Checked this with the latest Spyder version (6.0.4 as I write this) and I was able to reproduce this using the UMR feature.

Further checking, seems like disabling UMR (Preferences > Python interpreter > User Module Reloader (UMR)) and instead using the IPython console Autoreload option (Preferences > IPython console > Advanced settings > Autoreload) should be enough to be able to reload modules used in the from Modules import my_module to use functions using my_module.my_func():

Image

Let us know if the info above helps!

@hbengtsson
Copy link

Hi @dalthviz,

This seems to resolve the issue. Thank you for following up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants