These are chat archives for spyder-ide/public

16th
Apr 2019
vfzaitsev
@vfzaitsev
Apr 16 07:31

I work in Windows 10. 04/15/2019 I installed Spider 3.3.4.
The operator “for I in range (5) : print (i)”
works, and the operator
“for I in range (5) :
print (i)”
does not work.
A message is displayed:
“for i in range(5):
File "<ipython-input-67-aa82eeb25f1e>", line 1
for i in range(5):
^
SyntaxError: unexpected EOF while parsing’.

But it all works in the IDLE and PyCharm.
What is the reason ?

Carlos Cordoba
@ccordoba12
Apr 16 08:32
@vfzaitsev, are you trying to run that line alone with F9?
vfzaitsev
@vfzaitsev
Apr 16 09:32
Yes, with F9
All default Spyder settings
And this is the first operator in the program.
Everything was installed through Anaconda.
vfzaitsev
@vfzaitsev
Apr 16 09:39
I deleted Anaconda and set again.
Spyder 3.3.2 doesn't work either
vfzaitsev
@vfzaitsev
Apr 16 09:44
Carlos ! I'm just learning Python. I live in Kiev, Ukraine, Europe.
vfzaitsev
@vfzaitsev
Apr 16 09:51
We have now 12 hours 49 minutes of the day
Carlos Cordoba
@ccordoba12
Apr 16 11:11
@vfzaitsev, the problem is you can only use F9 to run lines that have complete Python statements, for example a = 10. The line you're trying to run (i.e. for i in range(5):) is not a complete statement because the inner body of the for loop is missing. That's why you're getting an error

There are two solutions to this:

  1. Select the entire for loop with the mouse and press F9
  2. Create a cell in your code by adding this comment #%% above the definition of your for loop, like this
#%%
for I in range (5) :
    print(i)

Then, by pressing Shift+Enter in any line below that comment, you can evaluate the contents of that region without selecting them with the mouse

vfzaitsev
@vfzaitsev
Apr 16 11:29
Thank ! 1) With mouse selection works. 2) With #%% - no. Where to put the cursor after #%% ? At the beginning of the line with the symbol #%% ? Or in for ? Or in print ?
Carlos Cordoba
@ccordoba12
Apr 16 11:30
In the for and pressing Shift+Enter (at the same time) afterwards
vfzaitsev
@vfzaitsev
Apr 16 11:40
I do not understand. Does not work. I typed #%% in the line before the operator for. Immediately press two keys?
But it is not "deadly." I can select with the mouse. Thanks for teaching!
LoenderslootR
@LoenderslootR
Apr 16 13:20
I try to update Spyder in Anaconda (Windows PC), as it - for some unclear reason - seems not to recognise it has PyQt5. Any suggestion... it says to type in windows cmd "conda update qt pyqt" but that is not recognised...
vfzaitsev
@vfzaitsev
Apr 16 13:40
Dear Carlos ! I have not yet grown to use PyQt5, but your advice on allocating a block of commands with the mouse helped me a lot today !
Great success to you !
Carlos Cordoba
@ccordoba12
Apr 16 13:44
Glad to know!
LoenderslootR
@LoenderslootR
Apr 16 13:51
How to resolve this error? ModuleNotFoundError: No module named 'PyQt5.QtMultimedia'; as far as I can see PyQt is installed properly. Spyder fails to find it...
Just running the program via cmd works (python <filenam.py>), so PyQt5 is installed properly; Spyder problem, but how to solve...
CAM Gerlach
@CAM-Gerlach
Apr 16 16:41
@LoenderslootR Most likely, the python you are running in the command prompt is not the same executable/running in the same environment as the one Spyder is launching your consoles in by default. See our guide to working with packages and environments with Spyder for more on this.
Selah Lynch
@selahlynch
Apr 16 16:43
Hi, does anyone know if it should be feasible to display interactive matplotlib graphics that are generated via connection to a remote spyder kernel? I've spent about an hour troubleshooting this and just want to know if there is a light at the end of the tunnel. For context, if I ssh -X to a server and run matplotlib code in an ipython session, my interactive matplotlib graphics show up fine. Also, connecting and using the variable explorer both work great with my remote spyder kernel.
CAM Gerlach
@CAM-Gerlach
Apr 16 16:49
@selahlynch Did you try different graphics backends with %matplotlib magics? Did you try plt.show()? If all else fails, you can savefig them and SCP them back.
Selah Lynch
@selahlynch
Apr 16 16:51
I tried some, but not all, maybe I'll spend a little more time on that. And yes, that's a nice workaround solution.
Would you say you think it should be possible to get it working? If so, I'll keep at it!
Albert Camin
@albertcamin
Apr 16 17:16
@CAM-Gerlach Thank you! The point is that when using the Anaconda prompt and introducing this comand "python -m pydoc -w .\card.py", the answer is that pydoc doen't exist in the computer.
CAM Gerlach
@CAM-Gerlach
Apr 16 17:17
@albertcamin I'm not sure how that has anything to do with the Spyder IDE, sorry...
LoenderslootR
@LoenderslootR
Apr 16 17:57
@CAM-Gerlach : I just installed Anaconda, which then includes Python 3.7.3, so it should be running from the same environment, otherwise I would not know which environment python uses....
CAM Gerlach
@CAM-Gerlach
Apr 16 18:02
When running the problem via the "command line" (do you mean the Anaconda prompt?), before running it, run the command where python and ensure the first path listed matches the path listed when running sys.executable in the IPython prompt in Spyder. If it doesn't, follow the guide. If it does, try changing the graphics backend in Preferences -> IPython Console -> Graphics Backend, restarting your IPython Console and retrying; since Spyder itself uses PyQt5 for its GUI (through QtPy) and intercepts certain calls to render plots inline, this may resolve it.
LoenderslootR
@LoenderslootR
Apr 16 18:06
package PyQt is in c:\ProgramData\Anaconda3\pkgs\, python is in c:\ProgramData\Anaconda3, the default directory for Anaconda... Indeed Anaconda prompt, sys.executable gives:
Out[3]: 'C:\ProgramData\Anaconda3\pythonw.exe' so should be ok....
CAM Gerlach
@CAM-Gerlach
Apr 16 18:07
To be sure, please give the exact output of where python in the console you used to successfully run python <filename.py> like I asked.
LoenderslootR
@LoenderslootR
Apr 16 18:09
(base) C:\ProgramData\Anaconda3\Scripts>where python
C:\ProgramData\Anaconda3\python.exe
CAM Gerlach
@CAM-Gerlach
Apr 16 18:10
Okay, just wanted to make sure. It appears you are using Anaconda prompt; I wanted to ensure you didn't have another python on your system that a plain command prompt was resolving. In that case, please follow the above instructions to change the graphics backend, restart your IPython console and retry.
LoenderslootR
@LoenderslootR
Apr 16 18:17

Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 7.4.0 -- An enhanced Interactive Python.

runfile('D:/Onderzoek/209-25212_Comenius-Teaching-Fellow/Python/study-tool-master/SHCMABLtool.py', wdir='D:/Onderzoek/209-25212_Comenius-Teaching-Fellow/Python/study-tool-master')
Traceback (most recent call last):

File "<ipython-input-1-c5b5117af840>", line 1, in <module>
runfile('D:/Onderzoek/209-25212_Comenius-Teaching-Fellow/Python/study-tool-master/SHCMABLtool.py', wdir='D:/Onderzoek/209-25212_Comenius-Teaching-Fellow/Python/study-tool-master')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/Onderzoek/209-25212_Comenius-Teaching-Fellow/Python/study-tool-master/SHCMABLtool.py", line 8, in <module>
from PyQt5.QtMultimediaWidgets import QVideoWidget

ModuleNotFoundError: No module named 'PyQt5.QtMultimedia'

LoenderslootR
@LoenderslootR
Apr 16 18:26
Earlier the code did run - separate python installation - now even plainly running it from the Windows commandline gives:

D:\Onderzoek\209-25212_Comenius-Teaching-Fellow\Python\study-tool-master>python SHCMABLtool.py
Traceback (most recent call last):
File "SHCMABLtool.py", line 8, in <module>
from PyQt5.QtMultimediaWidgets import QVideoWidget
ImportError: DLL load failed: The specified module could not be found.

D:\Onderzoek\209-25212_Comenius-Teaching-Fellow\Python\study-tool-master>

CAM Gerlach
@CAM-Gerlach
Apr 16 18:30
Whatever is going on in your latter example, Spyder of course has no control over. Again, did you try changing the graphics backend, restarting your console and retrying as I've asked you to several times now?
CAM Gerlach
@CAM-Gerlach
Apr 16 18:40
@selahlynch Do the plots work if you set %matplotlib inline in the external console? Worked for me just fine testing a locally-started kernel.
LoenderslootR
@LoenderslootR
Apr 16 19:01
@CAM-Gerlach yes... I did do that...
Selah Lynch
@selahlynch
Apr 16 19:03
@CAM-Gerlach ah hah, if change the backend via preferences and run %matplotlib inline I am able to see inline plots. That's great for now. Someday I'll work on the interactive part...
Thanks!!
CAM Gerlach
@CAM-Gerlach
Apr 16 19:03
Great!
@LoenderslootR So you tried all the different backends, restarting consoles in between? If so, try unchecking Activate support above that.
And did you read and follow our wiki page about this?
LoenderslootR
@LoenderslootR
Apr 16 19:36
Just installing python directly (3.7.3) via window commandline, installing the package PyQt5 (turns out to be version 5.12.1) via pip3 simply works. Don't understand why Spyder does not want to run - but I give up on it.....
CAM Gerlach
@CAM-Gerlach
Apr 16 19:39
@LoenderslootR You can try the option Execute in an external system terminal in Spyder, and you can also use this new Python environment you created inside of Spyder by installing spyder-kernels and setting it under Preferences -> Python Interpreter -> Use the following Python interpreter.