简体   繁体   English

VS code python 交互终端找不到代码变化

[英]VS code python interactive terminal doesn't find changes in code

I have a module that contains a class and a couple of functions that I will call package.我有一个模块,其中包含一个 class 和几个我将称之为 package 的函数。 The directory of that package is added to PYTHONPATH in the.bashrc (I'm on linux) and and in the interactive jupyter window I navigated to the directory of the package via os.chdir(). package 的目录已添加到 .bashrc 中的 PYTHONPATH(我在 linux 上)和交互式 jupyter window 我通过 osA3 导航到 ZEFE90A8E604A7C840E88D03 的目录。 VS code is using my global python installation. VS 代码正在使用我的全局 python 安装。

I have a script script.py that imports the module and calls the function f1().我有一个脚本 script.py 导入模块并调用 function f1()。 Something like就像是

import package

example = package.class1()
example.f1()

I can run the function and it produces output in the interactive python window.我可以运行 function 并在交互式 python Z05B8C74CBD96FFB244C1A3527 中生成 output。 However, if I do changes in the script, let's say I change a variable or add a print('something') function somewhere, nothing changes.但是,如果我在脚本中进行了更改,假设我更改了一个变量或在某处添加了 print('something') function,没有任何变化。 If I run the code in the terminal (not the interactive python thing), the output is produced correctly.如果我在终端中运行代码(不是交互式 python 东西),则 output 会正确生成。 Why doesn't the interactive python window see these changes?为什么交互式 python window 看不到这些变化?

Based on the information you provided, I reproduced the problem you described: When the content of this document is changed, " Interactive " will be changed accordingly;根据您提供的信息,我转载了您描述的问题:当本文档内容发生变化时,“ Interactive ”也会随之变化; When the content of the called file is changed, " Interactive " will not automatically update the data.当被调用文件的内容发生变化时,“ Interactive ”不会自动更新数据。

We need to click the refresh button above " Interactive " to update the cache content and the data will be updated accordingly.我们需要点击“ Interactive ”上方的refresh button来更新缓存内容,数据也会相应更新。 (Or reopen an "Interactive".) Obviously, using the previous cache when calling will shorten the running time and improve efficiency. (或者重新打开一个“Interactive”。)显然,调用时使用之前的缓存会缩短运行时间,提高效率。

Thank you for posting this problem here, we have submitted it, and let us look forward to a better solution.感谢您在这里发布这个问题,我们已经提交了,让我们期待更好的解决方案。

Github link: When the content of the called file is changed, "Interactive" does not update the data accordingly . Github 链接:当被调用文件的内容发生变化时,“交互”不会相应地更新数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM