简体   繁体   中英

Spyder - how to execute python script in the current console?

I've updated conda and spyder to the latest versions. I want to execute python scripts (using F5 hotkey) in the current console. However, the new spyder behaves unexpectedly, for example, if I enter in a console a=5 and then run test.py script that only contains a command print(a) , there is an error: NameError: name 'a' is not defined .

In the configuration options (command+F6) I've checked "Execute in current console" option. I am wondering why is this happening?

Conda 4.8.2, Spyder 4.0.1

In the preferences, run settings, there is a "General settings", in which you can (hopefully still) deactivate "Remove all variables before execution".

I even think to remember that this is new, so it makes sense.

I figured out the answer: In run configuration (command+F6) there is another option that needs to be checked: "Run in console's namespace instead of empty one"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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