Python Multiprocessing error: AttributeError: module ‘__main__’ has no attribute ‘__spec__’

The problem is not with the code / Python 3.6, it is with Spyder. After some investigation I found that the code runs fine when executed in an external system terminal but not when run in Spyder’s IPython console. I was able to dump the contents of spec and assign them to a variable that … Read more

Code to clear console and variables in Spyder

(Spyder maintainer here) This code both clears the console and removes all variables present on the namespace at the same time: try: from IPython import get_ipython get_ipython().magic(‘clear’) get_ipython().magic(‘reset -f’) except: pass It also has the advantage that it works inside and outside Spyder. Note: Right now this approach generates an error in the console after … Read more

How to change the path of Python in Spyder?

Press CTRL+SHIFT+ALT+P to open the Preferences window. Within this window, select the Console item on the left, then the Advanced Settings tab. The path to the Python executable will be right there. Update: For later versions please navigate to Tools -> Preferences -> Python Interpretor Additionally, you might also need to follow an additional step … Read more

Why do I get the syntax error “SyntaxError: invalid syntax” in a line with perfectly valid syntax?

When an error is reported on a line that appears correct, try removing (or commenting out) the line where the error appears to be. If the error moves to the next line, there are two possibilities: Either both lines have a problem (and the second may have been hidden by the first); or The previous … Read more