Spyder Ipython console completely ignores print statements - python

After I did some upgrade, I noticed If I'm printing in a script or even in the console, nothing is shown. I even remember in a previous version (I did a lot of upgrades recently) there was a tab right next to Ipython where the print output was showing, but after upgrading Spyder, it's gone. I've also been getting a lot of kernel died, restarting, and it's been really close to unusable. I used to love spyder, now I waste too much time closing/restarting/resetting just to get my work done.
I'm using Anaconda 3.5.
And just while I was writing this post, a tab called "Internal console" just popped up from nowhere and tells me the following:
Spyder Internal Console
This console is used to report application
internal errors and to inspect Spyder
internals with the following commands:
spy.app, spy.window, dir(spy)
Please don't use it to run your code
>>> WARNING:root:kernel died: 6.001342296600342
WARNING:root:kernel died: 6.000344276428223
Traceback (most recent call last):
File "C:\Users\Ahmad\Anaconda3\lib\site-packages\qtconsole\console_widget.py", line 412, in eventFilter
return self._event_filter_console_keypress(event)
File "C:\Users\Ahmad\Anaconda3\lib\site-packages\qtconsole\frontend_widget.py", line 381, in _event_filter_console_keypress
return super(FrontendWidget, self)._event_filter_console_keypress(event)
File "C:\Users\Ahmad\Anaconda3\lib\site-packages\qtconsole\console_widget.py", line 1130, in _event_filter_console_keypress
self.copy()
File "C:\Users\Ahmad\Anaconda3\lib\site-packages\qtconsole\frontend_widget.py", line 249, in copy
was_newline = text[-1] == '\n'
IndexError: string index out of range

Spyder lets you configure your run options. You can run in an external console or in your current python or ipython console. Maybe the default changed when you upgraded?
http://www.southampton.ac.uk/~fangohr/blog/spyder-the-python-ide.html#run-settings

Related

Error processing line 1 of distutils-precedence.pth (no module named '_distutils_hack')

I'm on Windows 10 and working in a git-bash terminal with anaconda environment. When I open a new terminal, I'm immediately presented with:
Error processing line 1 of C:\Users\e360769\AppData\Local\miniforge3\lib\site-packages\distutils-precedence.pth:
Traceback (most recent call last):
File "C:\Users\e360769\AppData\Local\miniforge3\lib\site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named '_distutils_hack'
Remainder of file ignored
This same error comes up any time I run "pip" or "python" on the command line. The command still executes correctly, but only after displaying that error. Note that this started after installing a collection of packages needed for a project I'm working with, and after investigating I found some people attributed this to the setuptools package (I have v41.2.0), but even when I uninstall it, the issue persists. Also note that this is the contents of my distutils-precedence.pth file:
import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'local') == 'local'; enabled and __import__('_distutils_hack').add_shim();
I'm not sure this is actively (for now) causing any issues with executing my python scripts, etc., but I'd like to know what's going on and how to fix this. Would appreciate any help!

PyCharm 2019.2 not showing Traceback on Exception

Very simple minimal example:
if __name__ == '__main__':
print("Still ok")
raise Exception("Dummy exception")
print("End of Program")
I get this output when running it in the PyCharm 2019.2 debugger with Python 3.6:
/usr/bin/python3.6 /home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 46850 --file /home/[...]/test_traceback.py
pydev debugger: process 18394 is connecting
Connected to pydev debugger (build 192.5728.105)
Still ok
At this point the debugger breaks the execution flow but no Traceback and Exception message is shown in the Debugger console. If I run the same in PyCharm 2018.1 it does show these right when the breakpoint is hit.
When I hit , I get the desired output, but then I can't run code in the debugging context anymore because the process ends:
Traceback (most recent call last):
File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 2060, in <module>
main()
File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 2054, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 1405, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 1412, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/[...]/pycharm-community-2019.2/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/[...]/test_traceback.py", line 4, in <module>
raise Exception("Dummy exception")
Exception: Dummy exception
Process finished with exit code 1
My Breakpoint configuration:
It works on PyCharm (Community) 2019.1.4:
Seems like you ran into a (regression) bug:
[JetBrains.YouTrack]: No Traceback in Debugger's Console
[JetBrains.YouTrack]: No stack trace is printed to the console when debugger breaks on exception
which affects v2019.2.1, and is scheduled to be fixed in v2019.2.3.
To get past this issue, you'll have to either:
Wait for v2019.2.3 (or any other that has the fix) to be released, and switch to that (might want to (periodically) check [JetBrains.Blog]: Release Announcements)
Revert to a (previous) version which is not affected by the bug (as I already mentioned: 2019.1.4)
As a note: when running into this kinds of situations, in the (unlikely) case that the problem is not yet known, one could take matters into their own hands, do some debugging, and fix the problem (maybe submit a patch with the fix to JetBrains). Check [SO]: Run / Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? for an example.
Update #0
Installed (on 20190930) latest patch (v2019.2.3), and the traceback is present in PyCharm's console (so, the bug is fixed).
did you check your whitespaces at start of each executable line? one time it occured to me was fixed after just correcting the whitespaces.

No Python IDE will start and it will not start in the Command Prompt

When I click on my Python IDE's (IDEL, PyScripter) they will not even open. I tried typing python in the command prompt and this is what happened:
C:\>python
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.5\lib\site.py", line 548, in <module>
main()
File "C:\Python27\ArcGIS10.5\lib\site.py", line 537, in main
aliasmbcs()
File "C:\Python27\ArcGIS10.5\lib\site.py", line 469, in aliasmbcs
codecs.lookup(enc)
File "C:\Python27\ArcGIS10.5\lib\encodings\__init__.py", line 85, in search_function
norm_encoding = normalize_encoding(encoding)
File "C:\Python27\ArcGIS10.5\lib\encodings\__init__.py", line 57, in normalize_encoding`enter code here`
encoding = str(encoding, "ascii")
TypeError: str() takes at most 1 argument (2 given)
Did you recently install ArcGIS? It looks to me like ArcGIS installed a few libraries, and overwrote your site.py, but it's using code that's meant for Python3 rather than Python2.7. The str function is capable of taking in 2 arguments in Python3 but not in Python2.
To get your Python to work again, you could try deleting the entire ArcGIS10.5 directory from your computer (or temporarily moving it to your desktop and seeing if that helps). You can also try running python -S in Command Prompt to run Python without importing site.py.
To try to get ArcGIS working, you might be able to install Python3, and reinstall ArcGIS using that.
Hopefully that helps!

Enthought Canopy crashes upon opening mac

So yesterday I updated to Enthought version 1.1 and now it refuses to open. I've rebooted my computer as well as did a re-install of enthought canopy. I keep getting the following error
Traceback (most recent call last):
File "build/bdist.macosx-10.5-i386/egg/canopy/app/bootstrap.py", line 1989, in main
File "build/bdist.macosx-10.5-i386/egg/canopy/app/bootstrap.py", line 1021, in main
File "build/bdist.macosx-10.5-i386/egg/canopy/app/bootstrap.py", line 1012, in _ kill_leftover_procs
File "build/bdist.macosx-10.5-i386/egg/canopy/app/running_process_manager.py", line 116, in kill_leftover_procs
File "/Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "build/bdist.macosx-10.5-i386/egg/canopy/app/running_process_manager.py", line 59, in lock
LockError: Lock could not be acquired
I have no idea what's going on here. I've sent the error report to enthought but does anyone have any ideas?
I think I did it. Try searching for these files in your Terminal. They're inside your .canopy folder. Make sure that you're working on your root directory. They're not searchable via Finder. My Canopy's finally working now. Hope this helps.
proc_manager.lock
process.lck
running_procs.pkl
Somehow it seems like a lock file didn't get cleaned in the process. Look into the ~/.canopy folder and remove the process.lck file. You may also start your Activity Monitor and make sure there is no stray canopy or python process, and kill it if there is (or log out of OSX and log back in, which will do the same thing). Canopy will run as normally after that.

Ipython installation on 3.3 x64 errors

I don't have experience in downloading libraries, so any help is appreciated. I've got a fresh install of Python3.3 and am trying to get IPython for 64bit Windows 7. The IPython .exe installer ran fine and completed normally, but I can't access the program. I looked through their documentation, and tried the commands there, but
$ python setup.py install
returns invalid syntax, highlighting "setup". I thought the fix might be in the distribute library mentioned on the page, so I went to go try and get that first. However, using the script from distribute's install page revealed it's own errors, namely
Traceback (most recent call last):
File "C:\Python33\distribute_setup.py", line 541, in <module>
sys.exit(main())
File "C:\Python33\distribute_setup.py", line 537, in main
tarball = download_setuptools(download_base=options.download_base)
File "C:\Python33\distribute_setup.py", line 200, in download_setuptools
log.warn("Downloading %s", url)
File "C:\Python33\lib\distutils\log.py", line 47, in warn
self._log(WARN, msg, args)
File "C:\Python33\lib\distutils\log.py", line 30, in _log
if stream.errors == 'strict':
AttributeError: errors
I've been at it for a couple hours now, and I'm fresh out of ideas. What next?
It looks like you ran into Python bug 12967. You need to run distribute_setup.py outside of IDLE (i.e. in a command prompt).

Categories