Python: Spyder crashed and doesn't open anymore - python

I use Spyder to run my python codes in my Mac OS x.
It happens that spyder just crashed, and since them it doesn't open anymore.
When I try to open it directly from ~/anaconda/bin, the following error msg appears:
Image of the error
after I click in ok, I get back the lines of error:
[Julias-MBP-3:~/anaconda/bin] juliaroquette% ./spyder
2017-06-19 18:24:06.479 python[713:16813] modalSession has been exited prematurely - check for a reentrant call to endModalSession:
Traceback (most recent call last):
File "/Users/juliaroquette/anaconda/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 3011, in main
mainwindow = run_spyder(app, options, args)
File "/Users/juliaroquette/anaconda/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 2913, in run_spyder
main.setup()
File "/Users/juliaroquette/anaconda/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 784, in setup
from spyder.plugins.help import Help
File "/Users/juliaroquette/anaconda/lib/python2.7/site-packages/spyder/plugins/help.py", line 33, in <module>
from spyder.utils.help.sphinxify import (CSS_PATH, generate_context,
File "/Users/juliaroquette/anaconda/lib/python2.7/site-packages/spyder/utils/help/sphinxify.py", line 29, in <module>
from docutils.utils import SystemMessage as SystemMessage
File "/Users/juliaroquette/anaconda/lib/python2.7/site-packages/docutils/utils/__init__.py", line 20, in <module>
import docutils.io
File "/Users/juliaroquette/anaconda/lib/python2.7/site-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/Users/juliaroquette/anaconda/lib/python2.7/site-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/Users/juliaroquette/anaconda/lib/python2.7/locale.py", line 564, in getlocale
return _parse_localename(localename)
File "/Users/juliaroquette/anaconda/lib/python2.7/locale.py", line 477, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
I tried to do what the error msg suggest, and use the option --reset, but the same error still exist after that.
Anyone has any idea on how to solve this issue?

It is known that the MacPorts version of Spyder is raising this error:
ValueError: unknown locale: UTF-8
which doesn’t let it start correctly.
To fix it you will have to set these environment variables in your .profile (or .bashrc) manually:
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Related

Issues Opening Spyder via Anaconda

I was forced into some software updates on my laptop (ThinkPad) and after the update when I tried to open Spyder (via Anaconda) and it won't open. I don't have any experience in errors like this or fixing this stuff (and I am aware this may be something that is super simple). Please help. This is the application launch error I am getting:
Traceback (most recent call last):
File "C:\Users\cyrra\anaconda3\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\app\start.py", line 205, in main
mainwindow.main()
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3651, in main
mainwindow = run_spyder(app, options, args)
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3526, in run_spyder
main.setup()
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 871, in setup
self.help = Help(self, css_path=css_path)
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\plugins\help\plugin.py", line 68, in __init__
color_scheme = self.get_color_scheme()
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\api\plugins.py", line 347, in get_color_scheme
return super(BasePluginWidget, self)._get_color_scheme()
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\plugins\base.py", line 446, in _get_color_scheme
return get_color_scheme(CONF.get('appearance', 'selected'))
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\config\gui.py", line 114, in get_color_scheme
color_scheme[key] = CONF.get("appearance", "%s/%s" % (name, key))
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\config\manager.py", line 228, in get
return config.get(section=section, option=option, default=default)
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\config\user.py", line 976, in get
return config.get(section=section, option=option, default=default)
File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder\config\user.py", line 513, in get
raise cp.NoOptionError(option, section)
configparser.NoOptionError: No option 'custom-1/background' in section: 'appearance'
Thanks,
Rachel
Did you try to run spyder on the terminal?
It should be prebuild in Anaconda.
Your Spyder config file should contain but is missing 'custom-1/background' in section: 'appearance'. If you have no experience, the easiest thing for you to do is uninstall and install Spyder (via Anaconda). Your other option is to find the config file called in line 513 of C:\Users\cyrra\anaconda3\lib\site-packages\spyder\config\user.py". Then open the config file (if it exists) and correct it. If the file is not found, search for that config file and place it in the expected location.

After starting spyder: ImportError: cannot import name 'quick_guide'

When I start spyder the internal console pops up and gives the following "traceback":
>>> WARNING:traitlets:kernel died: 6.001837253570557
Traceback (most recent call last):
File "C:\...\lib\site-packages\traitlets\traitlets.py", line 528, in get
value = obj._trait_values[self.name]
KeyError: 'banner'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\...\lib\site-packages\qtconsole\base_frontend_mixin.py", line 163, in _dispatch
handler(msg)
File "C:\...\lib\site-packages\qtconsole\jupyter_widget.py", line 296, in _handle_kernel_info_reply
super(JupyterWidget, self)._started_channels()
File "C:\...\lib\site-packages\qtconsole\frontend_widget.py", line 617, in _started_channels
self.reset(clear=True)
File "C:\...\lib\site-packages\qtconsole\frontend_widget.py", line 661, in reset
self._append_plain_text(self.banner)
File "C:\...\lib\site-packages\traitlets\traitlets.py", line 556, in __get__
return self.get(obj, cls)
File "C:\...\lib\site-packages\traitlets\traitlets.py", line 535, in get
value = self._validate(obj, dynamic_default())
File "C:\...\lib\site-packages\spyder\widgets\ipythonconsole\shell.py", line 280, in _banner_default
return self.long_banner()
File "C:\...\lib\site-packages\spyder\widgets\ipythonconsole\shell.py", line 91, in long_banner
from IPython.core.usage import quick_guide
ImportError: cannot import name 'quick_guide'
The IPython console works without problems, it is just missing the "introduction text" (python version, help-commands).
Can I just ignore this exception or is there a way to fix this manually?
(Spyder developer here) This was fixed in Spyder 3.1.4 (just released). Please update to fix it.
To fix the exception manually one needs to change the last mentioned file in the traceback. In this case this one:
File "C:\...\lib\site-packages\spyder\widgets\ipythonconsole\shell.py", line 91, in long_banner
from IPython.core.usage import quick_guide
ImportError: cannot import name 'quick_guide'
and change quick_guide to quick_reference as quick_guide. One may need to restart Spyder but then the Exception disappeared.
I solved:
Only use conda install spyder=3.1.4 in your conda env.
Regards.

What does this capistrano error mean when doing an AWS file fetch via cap tasks?

In my deploy/development.rb, I have the following line:-
set :env_path, 's3api get-object --bucket <bucket_name> --key <file_name> <file_name>'
In my cap file, I have the following task defined:
task :download_configs do
on roles(:all) do
within release_path do
execute :aws, "#{fetch(:env_path)}"
end
end
# on roles(:db) do
# within release_path do
# execute :aws, "#{fetch(:env_path)}"
# end
# end
end
But on cap deploy,I am seeing the following errors:-
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as ubuntu#54.213.226.117: aws exit status: 1
aws stdout: Traceback (most recent call last):
File "/usr/bin/aws", line 15, in <module>
import awscli.clidriver
File "/usr/share/awscli/awscli/clidriver.py", line 30, in <module>
from awscli.help import ProviderHelpCommand
File "/usr/share/awscli/awscli/help.py", line 20, in <module>
from docutils.core import publish_string
File "/usr/lib/python3/dist-packages/docutils/core.py", line 20, in <module>
from docutils import frontend, io, utils, readers, writers
File "/usr/lib/python3/dist-packages/docutils/frontend.py", line 41, in <module>
import docutils.utils
File "/usr/lib/python3/dist-packages/docutils/utils/__init__.py", line 20, in <module>
import docutils.io
File "/usr/lib/python3/dist-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/usr/lib/python3/dist-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/usr/lib/python3.4/locale.py", line 556, in getdefaultlocale
return _parse_localename(localename)
File "/usr/lib/python3.4/locale.py", line 484, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
aws stderr: Nothing written
SSHKit::Command::Failed: aws exit status: 1
aws stdout: Traceback (most recent call last):
File "/usr/bin/aws", line 15, in <module>
import awscli.clidriver
File "/usr/share/awscli/awscli/clidriver.py", line 30, in <module>
from awscli.help import ProviderHelpCommand
File "/usr/share/awscli/awscli/help.py", line 20, in <module>
from docutils.core import publish_string
File "/usr/lib/python3/dist-packages/docutils/core.py", line 20, in <module>
from docutils import frontend, io, utils, readers, writers
File "/usr/lib/python3/dist-packages/docutils/frontend.py", line 41, in <module>
import docutils.utils
File "/usr/lib/python3/dist-packages/docutils/utils/__init__.py", line 20, in <module>
import docutils.io
File "/usr/lib/python3/dist-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/usr/lib/python3/dist-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/usr/lib/python3.4/locale.py", line 556, in getdefaultlocale
return _parse_localename(localename)
File "/usr/lib/python3.4/locale.py", line 484, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
aws stderr: Nothing written
Please help me identify what is going wrong here!
Shot in the dark (I'm not a Python dev), but you might be able add the following to deploy.rb:
set :default_env, {
'LANG' => 'en_US.UTF-8'
}
Derived mostly from https://github.com/matplotlib/matplotlib/issues/5420#issuecomment-154454607
I would check to see if you can run the command manually on the server. If you cannot, then figure out how to without Capistrano. If you can, perhaps see if there is some configuration in .bashrc or .bash_profile that can be added to the Capistrano config.

matplotlib does not import in python3 [duplicate]

This question already has answers here:
Pelican 3.3 pelican-quickstart error "ValueError: unknown locale: UTF-8"
(6 answers)
Closed 6 years ago.
I have OSX El capitan, and get the following error when trying to import matplotlib in python 3:
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/__init__.py", line 1131, in <module>
rcParams = rc_params()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/__init__.py", line 975, in rc_params
return rc_params_from_file(fname, fail_on_error)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/__init__.py", line 1100, in rc_params_from_file
config_from_file = _rc_params_in_file(fname, fail_on_error)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/__init__.py", line 1018, in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py", line 59, in __enter__
return next(self.gen)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/__init__.py", line 1000, in _open_file_or_url
encoding = locale.getdefaultlocale()[1]
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/locale.py", line 559, in getdefaultlocale
return _parse_localename(localename)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/locale.py", line 487, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
I tried to delete the matplotlib folder, and reinstall it with pip install matplotlib, which it recreates it, but it ends up giving the same error.
I already spend half the weekend trying to find an answer but no luck - maybe somebody can help.
Best
Found a solution here. Basically what you have to do is add two lines to your ~/.bash_profile (and re-open terminal window):
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Cannot Import GTK in Ubuntu Python 2.7

I'm trying to import GTK in Ubuntu Python 2.7, and I get the following error. PyGTK imports just fine. When I import gtk, I get the following error:
Exception in Tkinter callback Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
return self.func(*args)
File "/usr/lib/python2.7/idlelib/MultiCall.py", line 167, in handler
r = l[i](event)
File "/usr/lib/python2.7/idlelib/PyShell.py", line 1140, in enter_callback
self.runit()
File "/usr/lib/python2.7/idlelib/PyShell.py", line 1181, in runit
more = self.interp.runsource(line)
File "/usr/lib/python2.7/idlelib/PyShell.py", line 619, in runsource
return InteractiveInterpreter.runsource(self, source, filename)
File "/usr/lib/python2.7/code.py", line 87, in runsource
self.runcode(code)
File "/usr/lib/python2.7/idlelib/PyShell.py", line 759, in runcode
self.tkconsole.endexecuting()
File "/usr/lib/python2.7/idlelib/PyShell.py", line 940, in endexecuting
self.showprompt()
File "/usr/lib/python2.7/idlelib/PyShell.py", line 1205, in showprompt
self.resetoutput()
File "/usr/lib/python2.7/idlelib/PyShell.py", line 1217, in resetoutput
if self.history:
File "/usr/lib/python2.7/idlelib/PyShell.py", line 64, in idle_showwarning
lineno, file=file, line=line))
TypeError: idle_formatwarning() got an unexpected keyword argument 'file'
How do I fix this?
This is a bug in idle. Looking at the last line of that error message:
File "/usr/lib/python2.7/idlelib/PyShell.py", line 64, in idle_showwarning
lineno, file=file, line=line))
TypeError: idle_formatwarning() got an unexpected keyword argument 'file'
This is saying that the warning.idle_showwarning method does not have an argument "file".
Sure enough looking at /usr/lib/python2.7/warnings.py
def formatwarning(message, category, filename, lineno, line=None)
There is no such argument.
This apparently has been resolved in source control but I do not think it has made it into a release yet. I would just hack the /usr/lib/python2.7/idlelib/PyShell.py file and remove the offending argument from line 64.
Then try it again...
Try it outside of IDLE. The error here is in IDLE, not your code.
Create a new script that contains import gtk and save it anywhere.
From the command line, in the directory where your script is located, run python whatever_your_scripts_name_is.py.
See if you get an error. You may not be able to import gtk in IDLE.
Edit: There is apparently a problem with GTK and IDLE in some situations on Ubuntu.
Try a different Python shell; I'd recommend IPython which you can install with Synaptic or sudo apt-get install ipython.

Categories