These are chat archives for spyder-ide/public

24th
Apr 2019
Gonzalo Peña-Castellanos
@goanpeca
Apr 24 01:22
This seems a pretty common issue. It should be probably identified by the linters (or we could even do this?)
CAM Gerlach
@CAM-Gerlach
Apr 24 01:36

@goanpeca Yeah, people have reported this one a lot, though mostly in the context of trying to start Spyder/a kernel and it crashing, because they shadowed a standard library module or something else critical that the kernel needs to start properly. To address the latter case (the one with the most relevance to Spyder), can we change the search path when starting the kernel to put the current directory at the end during kernel startup (except for dev builds), but make sure it is set to the normal path for user-facing code?

To warn about it for user-facing code, potentially we could check AttributeError messages in to determine if the module_name matches both a filename in the current directory, and one in the stdlib? Seems like a decent amount to work to catch an error a beginner is only likely to make once, but perhaps it would be worthwhile it we upstreamed it to some sort of special message/handling in IPython itself?

Mark B. Campanelli
@campanelli-resonon
Apr 24 15:01

Is there a insurmountable technical reason that the Variable Explorer doesn't work when connected to a non-Spyder-created IPython console?

https://docs.spyder-ide.org/ipythonconsole.html#supported-features

CAM Gerlach
@CAM-Gerlach
Apr 24 15:24
@campanelli-resonon Yes. However, if you create the IPython kernel with our spyder-kernels package, as we recommend there, all of those features will work (I tested them just now). Sorry if that's unclear, I can open an issue to clarify it.
Mark B. Campanelli
@campanelli-resonon
Apr 24 15:41
Ah ok. Sorry I misunderstood the spyder-kernels piece and instead created the console using "plain vanilla" IPython.embed_kernel(). Thanks for the further clarification :).
CAM Gerlach
@CAM-Gerlach
Apr 24 15:42

What part did you misunderstand, sorry? We explicitly state:

If using Spyder 3.3.0 or later, you’ll need to launch the kernel with python -m spyder_kernels.console (after you’ve first installed spyder-kernels on the host with <conda/pip> install spyder-kernels).

Mark B. Campanelli
@campanelli-resonon
Apr 24 15:50
That didn't seem to be my path because I'm trying to launch the IPython kernel from within my application, not from the command line. So now I'm looking for spyder-kernelsequivalent of IPython.embed_kernel(), or am I still confused here?
CAM Gerlach
@CAM-Gerlach
Apr 24 15:53
Oh, okay. Not sure if that's possible, since Spyder kernels are specifically designed to be used with Spyder and contain the necessary code to enable those Spyder features, but perhaps it could be. @ccordoba12 ? Other than that, you should still be able to connect to a vanilla IPython kernel, just without those features that require spyder-kernels.
Carlos Cordoba
@ccordoba12
Apr 24 16:29
I don't know if you can embed an Spyder kernel inside an application. But our kernel is simply a subclasss of an IPython kernel, so if you can do it with it, you can also do it with an Spyder kernel.
Mark B. Campanelli
@campanelli-resonon
Apr 24 16:33
That sounds promising, actually. I will try to embed the Spyder subclass and report back. Thanks again.
CAM Gerlach
@CAM-Gerlach
Apr 24 20:28
@campanelli-resonon Thanks for sharing, but please make those as a Gist (and link them here) and remove them from the above. Our public Gitter is just not a great place to share huge chunks of code, and and noone is going to be able to find it here after a couple days anyway. Thanks
Mark B. Campanelli
@campanelli-resonon
Apr 24 20:41
My apologies. Here's a gist for a quick and dirty way to embed a Spyder-compatible console into a Python app: https://gist.github.com/campanelli-resonon/5b4f4a5648f49716e9bf4995d0d3a0fc
CAM Gerlach
@CAM-Gerlach
Apr 24 20:55
Thanks @campanelli-resonon ! Hopefully others find that useful!
Carlos Cordoba
@ccordoba12
Apr 24 20:58
@campanelli-resonon, nice to know you found a way to embed our kernel in other Python apps! Kudos to you!
@CAM-Gerlach, I think we should add a link to @campanelli-resonon gist in our docs. What do you think?
Gonzalo Peña-Castellanos
@goanpeca
Apr 24 20:59
Definitely!
CAM Gerlach
@CAM-Gerlach
Apr 24 21:00
I was thinking about that; since its pretty specialized and more of a development-related item than about using the Spyder application itself, I was thinking it would make more sense included in our Wiki.
@campanelli-resonon We could just put the prose parts of your explanation in the wiki directly, and link to the longer full code file in the Gist. If you want to share a prose description (e..g. based on what you previously wrote above) perhaps with code snippets, we would be happy to include a full credit and link to your GH profile.
Mark B. Campanelli
@campanelli-resonon
Apr 24 22:08
I'm happy to help. Kudos to the IPython dev's who definitely anticipated this use case, and I'm still investigating the finer points of this composition of ideas. In particular I'm not totally sure that I'm getting graceful SpyderKernelAppshutdown. I'll check back in when I have something stable and nice.
CAM Gerlach
@CAM-Gerlach
Apr 24 22:08
One way is to just send quit as a console command; that does it for me.
Wynterwulfe
@Wynterwulfe
Apr 24 22:25
Hey.. I am a NEWBIE python learner.. I have heard that Spyder is a great IDE.. is there a executable to download Spyder and Python together for Windows?
CAM Gerlach
@CAM-Gerlach
Apr 24 22:28
@Wynterwulfe Yes, Anaconda. See the Download section right on the homepage of our website.
Wynterwulfe
@Wynterwulfe
Apr 24 22:29
Thanks.. I would love to learn Python.. just not sure I can learn it from Youtube channels.. I am the kind of person that needs to ask questions as I go but have been unable to find a place local to where I live that teaches it..
Mark B. Campanelli
@campanelli-resonon
Apr 24 22:31
@CAM-Gerlach That seems to work, but I don't see any print() logging statements after the app.start() line that should no longer be blocking after the quit, so I'm not totally sure where the execution goes.
CAM Gerlach
@CAM-Gerlach
Apr 24 22:33
@Wynterwulfe I link a number of sites in the Emergency Numnbers section of the Spyder Troubleshooting Guide, and there are also a bunch of resources in Spyder's Help menu. And of course, if you have any questions that relate directly to the Spyder IDE (as opposed to more general Python, programming, data science or third party packages), feel free to ask them here. I can also point to toward specific ways Spyder can help Python newbies become an expert in the language and the scientific Python workflow.
@campanelli-resonon Not sure, depends on exactly how you have it set up, and I'm not really the expert in that area.
Mark B. Campanelli
@campanelli-resonon
Apr 24 22:40

I have another question. My app uses a pip workflow and I'd like to "prove out" using Spyder while still in Python2 before I start moving the app to Python3. Can I get Spyder running with PySide2 instead of PyQt5 in Python2, and does https://github.com/spyder-ide/qtpy factor in here somehow?

Also, what's the best way to launch Spyder in a separate Python process from within my app? I was hoping for some sort of "run" function to use as a target to my multiprocessing.Process() constructor.

CAM Gerlach
@CAM-Gerlach
Apr 24 22:52
QtPy is a Qt binding abstraction layer we develop and (along with a number of other applications) use, along with the similarly named alternative Qt.Py) that allows users to (theoretically, at least) swap in either of the two major Qt binding packages and have our code work the same in either of them. We used to support both PySide (before PySide2 existed), PyQt4 and PyQt5, but due to PySide's limitations, as well as slow support for Python 3 and reliance on the EoL Qt 4, we had to drop support a few years back (we finally dropped PyQt4 a year or so ago in Spyder 3.3.0). We hope to add Qt for Python support at some point (i.e. modern PySide2) if there's someone interested in developing it, once Qt 5.12 is built and stable on Anaconda (to allow us to use it with the biggest distribution that ships us) and it is mature enough, which should hopefully be soon...ish. We would welcome the help, if you might be willing to contribute, and I'm sure we would be more than happy to provide guidance.
@campanelli-resonon As for your second question, you can start it directly from mainwindow.py or with start.py, e.g. spyder.app.start.main() or spyder.app.mainwindow.main().