"autoreload of pydev_umd failed" exception when using %autoreload in Python Console

I have my python console set up to use IPython

I want modules to reload when I change their files so I added these these to my Python Console start up script.

%load_ext autoreload
%autoreload 2

The auto reload works but every time I change a file then run something in the console I get the following exception trace.

How can get rid of this?

Or is there another way to achieve reloading of modules when they change? 

 

[autoreload of pydev_umd failed: Traceback (most recent call last):
File "D:\opt\Miniconda3\envs\advanced-analytics\lib\site-packages\IPython\extensions\autoreload.py", line 245, in check
superreload(m, reload, self.old_objects)
File "D:\opt\Miniconda3\envs\advanced-analytics\lib\site-packages\IPython\extensions\autoreload.py", line 394, in superreload
module = reload(module)
File "D:\opt\Miniconda3\envs\advanced-analytics\lib\imp.py", line 314, in reload
return importlib.reload(module)
File "D:\opt\Miniconda3\envs\advanced-analytics\lib\importlib\__init__.py", line 168, in reload
raise ModuleNotFoundError(f"spec not found for the module {name!r}", name=name)
ModuleNotFoundError: spec not found for the module 'pydev_umd'
]

3

Hi, 

I could not reproduce the issue in PyCharm 2020.2.3, your solution works fine and autoreload works without errors. 

Which PyCharm version are you using? Try updating if you haven't yet: https://www.jetbrains.com/pycharm/download/

0

I get this all the time.
I can get it by making a change in a submodule that needs to be re-imported.
On the first run, after the change, I receive the traceback above - though the auto-re-import works.
On subsequent run, no traceback.

2

I have the exact same error in PyCharm 2022.3.1 (Professional Edition). 

2

Hello, 

 

Could you please submit an bug report 

at https://youtrack.jetbrains.com/issues/PY and attach a simplified project example with steps to reproduce? 

Thank you in advance! 

 

1

Hi Folks - I have created support tickets (with examples) on two separate occasions - and although I can reliably demonstrate the issue on both my home and work installations...I've never been able to get it reproducible w/ Jetbrains. Not sure why...

Some mystery here..

0

I have solved this problem. The module pydev_umd seems to be my main function. We can check it in the sys,modules. So the best way to solve it is to cancel reloading this module. Like the screencast.

0

I have tried this previously but somehow it does not really work. Jonetangball could you confirm that this fix solved your problem once and for all?

0

I asked ChatGPT, and hilariously it indicated the same solution.

%aimport -pydev_umd

Now..I believe ya gotta be using iPython, etc, etc.

0

I configure my console using iPython,and it does solve my problem.  The module Pydev_umd is something to do with my console. Even if I delete this module at the beginning of the program, it will not affect the operation of the entire program.

0

请先登录再写评论。