Repository: spyder-ide/spyder

Issue:
Error on saving generated by Pygments lexers
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

just saving or trying to open a file

here is my conda list info

<details>
```
segtovichisv@segtovichisv-dell-luos1604:~$ conda list
# packages in environment at /home/segtovichisv/anaconda3:
#
# Name                    Version                   Build  Channel
_license                  1.1                      py36_1  
_nb_ext_conf              0.4.0                    py36_1  
alabaster                 0.7.9                    py36_0  
anaconda                  custom           py36hbbc8b67_0  
anaconda-client           1.6.0                    py36_0  
anaconda-navigator        1.5.0                    py36_0  
anaconda-project          0.4.1                    py36_0  
assimulo                  2.9                      py36_5    conda-forge
astroid                   1.4.9                    py36_0  
astropy                   1.3                 np111py36_0  
babel                     2.3.4                    py36_0  
backcall                  0.1.0                    py36_0  
backports                 1.0                      py36_0  
beautifulsoup4            4.5.3                    py36_0  
bitarray                  0.8.1                    py36_0  
blas                      1.1                    openblas    conda-forge
blaze                     0.10.1                   py36_0  
bokeh                     0.12.4                   py36_0  
boto                      2.45.0                   py36_0  
bottleneck                1.2.0               np111py36_0  
ca-certificates           2018.1.18                     0    conda-forge
cairo                     1.14.12              h77bcde2_0  
certifi                   2018.8.13                py36_0  
cffi                      1.9.1                    py36_0  
chardet                   2.3.0                    py36_0  
chest                     0.2.3                    py36_0  
click                     6.7                      py36_0  
cloudpickle               0.2.2                    py36_0  
clyent                    1.2.2                    py36_0  
colorama                  0.3.7                    py36_0  
conda                     4.5.10                   py36_0  
conda-env                 2.6.0                h36134e3_1  
configobj                 5.0.6                    py36_0  
contextlib2               0.5.4                    py36_0  
cryptography              1.7.1                    py36_0  
cssselect                 1.0.3                     <pip>
curl                      7.52.1                        0  
cycler                    0.10.0                   py36_0  
Cython                    0.25.2                    <pip>
cython                    0.25.2                   py36_0  
cytoolz                   0.8.2                    py36_0  
dask                      0.13.0                   py36_0  
datashape                 0.5.4                    py36_0  
dbus                      1.10.22              h3b5a359_0  
decorator                 4.0.11                   py36_0  
dill                      0.2.5                    py36_0  
docutils                  0.13.1                   py36_0  
entrypoints               0.2.2                    py36_0  
et_xmlfile                1.0.1                    py36_0  
expat                     2.1.0                         0  
fastcache                 1.0.2                    py36_1  
flask                     0.12                     py36_0  
flask-cors                3.0.2                    py36_0  
fontconfig                2.12.4               h88586e7_1  
freetype                  2.8                  hab7d2ae_1  
get_terminal_size         1.0.0                    py36_0  
gevent                    1.2.1                    py36_0  
glib                      2.53.6               h5d9569c_2  
graphite2                 1.3.10               hf63cedd_1  
greenlet                  0.4.11                   py36_0  
gst-plugins-base          1.12.4               h33fb286_0  
gstreamer                 1.12.4               hb53b477_0  
h5py                      2.6.0               np111py36_2  
harfbuzz                  1.7.4                hc5b324e_0  
hdf5                      1.8.17                        1  
heapdict                  1.0.0                    py36_1  
icu                       58.2                 h9c2bf20_1  
idna                      2.2                      py36_0  
imagesize                 0.7.1                    py36_0  
ipykernel                 4.5.2                    py36_0  
ipython                   6.4.0                    py36_0  
ipython_genutils          0.1.0                    py36_0  
ipywidgets                7.2.1                    py36_0  
isort                     4.2.5                    py36_0  
itsdangerous              0.24                     py36_0  
jbig                      2.1                           0  
jdcal                     1.3                      py36_0  
jedi                      0.12.0                   py36_1  
jeepney                   0.3.1                    py36_0  
jinja2                    2.9.4                    py36_0  
jpeg                      9b                            0  
jsonschema                2.5.1                    py36_0  
jupyter                   1.0.0                    py36_3  
jupyter_client            5.2.3                    py36_0  
jupyter_console           5.0.0                    py36_0  
jupyter_core              4.4.0            py36h7c827e3_0  
keyring                   13.2.1                   py36_0  
Kivy                      1.10.0                    <pip>
Kivy-Garden               0.1.4                     <pip>
kiwisolver                1.0.1            py36h764f252_0  
lazy-object-proxy         1.2.2                    py36_0  
libedit                   3.1                  heed3624_0  
libffi                    3.2.1                         1  
libgcc                    4.8.5                         2  
libgcc-ng                 7.2.0                hdf63c60_3  
libgfortran               3.0.0                         1  
libiconv                  1.14                          0  
libpng                    1.6.34               hb9fc6fc_0  
libsodium                 1.0.10                        0  
libstdcxx-ng              7.2.0                hdf63c60_3  
libtiff                   4.0.9                h28f6b97_0  
libxcb                    1.12                          1  
libxml2                   2.9.4                         0  
libxslt                   1.1.29                        0  
llvmlite                  0.15.0                   py36_0  
lml                       0.0.1                     <pip>
locket                    0.2.0                    py36_1  
lxml                      3.7.2                    py36_0  
markupsafe                0.23                     py36_2  
matplotlib                2.2.2            py36h0e671d2_0  
metis                     5.1.0                         3    conda-forge
mistune                   0.7.3                    py36_0  
mkl                       2017.0.1                      0  
mkl-service               1.1.2                    py36_3  
mpmath                    0.19                     py36_1  
multipledispatch          0.4.9                    py36_0  
nb_anacondacloud          1.4.0                    py36_0  
nb_conda                  2.2.1            py36h8118bb2_0  
nb_conda_kernels          2.1.0                    py36_0  
nbconvert                 4.2.0                    py36_0  
nbformat                  4.2.0                    py36_0  
nbpresent                 3.0.2            py36h5f95a39_1  
ncurses                   6.0                  h9df7e31_2  
ndg-httpsclient           0.4.4                     <pip>
networkx                  1.11                     py36_0  
nltk                      3.2.2                    py36_0  
nose                      1.3.7                    py36_1  
notebook                  5.3.1                    py36_0  
numba                     0.30.1              np111py36_0  
numexpr                   2.6.1               np111py36_2  
numpy                     1.11.3          py36_blas_openblas_202  [blas_openblas]  conda-forge
numpydoc                  0.6.0                    py36_0  
odfpy                     1.3.5                     <pip>
odo                       0.5.0                    py36_1  
olefile                   0.45.1                   py36_0  
openblas                  0.2.19                        2    conda-forge
openpyxl                  2.4.1                    py36_0  
openssl                   1.0.2n                        0    conda-forge
pandas                    0.19.2              np111py36_1  
parso                     0.2.0                    py36_0  
partd                     0.3.7                    py36_0  
path.py                   10.0                     py36_0  
pathlib2                  2.2.0                    py36_0  
patsy                     0.4.1                    py36_0  
pcre                      8.39                          1  
pep8                      1.7.0                    py36_0  
pexpect                   4.2.1                    py36_0  
pickleshare               0.7.4                    py36_0  
pillow                    5.0.0            py36h3deb7b8_0  
pip                       9.0.1                    py36_1  
pixman                    0.34.0                        0  
ply                       3.9                      py36_0  
prompt_toolkit            1.0.9                    py36_0  
psutil                    5.0.1                    py36_0  
ptyprocess                0.5.1                    py36_0  
purl                      1.3.1                     <pip>
py                        1.4.22                    <pip>
py                        1.4.32                   py36_0  
pyasn1                    0.1.9                    py36_0  
pycodestyle               2.4.0                    py36_0  
pycosat                   0.6.3            py36h0a5515d_0  
pycparser                 2.17                     py36_0  
pycrypto                  2.6.1                    py36_4  
pycurl                    7.43.0                   py36_2  
pyexcel                   0.5.3                     <pip>
pyexcel-ezodf             0.3.3                     <pip>
pyexcel-io                0.5.1                     <pip>
pyexcel-ods               0.5.0                     <pip>
pyexcel-ods3              0.5.0                     <pip>
pyflakes                  1.5.0                    py36_0  
pygments                  2.1.3                    py36_0  
pylint                    1.6.4                    py36_1  
pyopenssl                 16.2.0                   py36_0  
pyparsing                 2.1.4                    py36_0  
pyqt                      5.6.0                    py36_2  
pytables                  3.3.0               np111py36_0  
pytest                    3.0.5                    py36_0  
pytest                    2.6.0                     <pip>
python                    3.6.3                hc9025b9_1  
python-base               1.1.8                     <pip>
python-dateutil           2.6.0                    py36_0  
pytz                      2016.10                  py36_0  
pyyaml                    3.12                     py36_0  
pyzmq                     16.0.2                   py36_0  
qt                        5.6.2               h974d657_12  
qtawesome                 0.4.3                    py36_0  
qtconsole                 4.2.1                    py36_1  
qtpy                      1.2.1                    py36_0  
readline                  7.0                  ha6073c6_4  
redis                     3.2.0                         0  
redis-py                  2.10.5                   py36_0  
requests                  2.12.4                   py36_0  
rope                      0.9.4                    py36_1  
ruamel_yaml               0.11.14                  py36_1  
scikit-image              0.12.3              np111py36_1  
scikit-learn              0.19.1          py36_blas_openblas_200  [blas_openblas]  conda-forge
scipy                     0.19.1          py36_blas_openblas_202  [blas_openblas]  conda-forge
seaborn                   0.7.1                    py36_0  
secretstorage             3.0.1                    py36_0  
send2trash                1.5.0                    py36_0  
setuptools                39.1.0                   py36_0  
setuptools                38.2.4                    <pip>
simplegeneric             0.8.1                    py36_1  
singledispatch            3.4.0.3                  py36_0  
sip                       4.18                     py36_0  
six                       1.10.0                   py36_0  
snowballstemmer           1.2.1                    py36_0  
sockjs-tornado            1.0.3                    py36_0  
Sphinx                    1.5.6                     <pip>
sphinx                    1.5.1                    py36_0  
sphinxcontrib-images      0.7.0                     <pip>
spyder                    3.3.1                    py36_1  
spyder-kernels            0.2.4                    py36_0  
sqlalchemy                1.1.5                    py36_0  
sqlite                    3.22.0               h1bed415_0  
statsmodels               0.6.1               np111py36_1  
suitesparse               4.5.4           blas_openblas_200  [blas_openblas]  conda-forge
sundials                  2.7.0           blas_openblas_3  [blas_openblas]  conda-forge
sympy                     1.0                      py36_0  
tbb                       2018_20171205                 0    conda-forge
terminado                 0.6                      py36_0  
texttable                 0.9.1                     <pip>
tk                        8.6.7                hc745277_3  
toolz                     0.8.2                    py36_0  
tornado                   4.4.2                    py36_0  
traitlets                 4.3.1                    py36_0  
unicodecsv                0.14.1                   py36_0  
uno                       0.3.3                     <pip>
unotools                  0.3.3                     <pip>
virtualenv                15.1.0                    <pip>
wcwidth                   0.1.7                    py36_0  
werkzeug                  0.11.15                  py36_0  
wheel                     0.29.0                   py36_0  
widgetsnbextension        3.2.1                    py36_0  
wrapt                     1.10.8                   py36_0  
xlrd                      1.0.0                    py36_0  
xlsxwriter                0.9.6                    py36_0  
xlwt                      1.2.0                    py36_0  
xz                        5.2.3                h55aa19d_2  
yaml                      0.1.6                         0  
zeromq                    4.1.5                         0  
zlib                      1.2.11               ha838bed_2 
```
</details>

### Traceback
```python-traceback
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/spyder/plugins/editor.py", line 2018, in save
    return editorstack.save(index=index, force=force)
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/spyder/widgets/editor.py", line 1588, in save
    return self.save_as(index=index)
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/spyder/widgets/editor.py", line 1719, in save_as
    filename = self.select_savename(original_filename)
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/spyder/widgets/editor.py", line 1664, in select_savename
    self.edit_filetypes = get_edit_filetypes()
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/spyder/config/utils.py", line 125, in get_edit_filetypes
    supported_exts = _get_pygments_extensions()
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/spyder/config/utils.py", line 87, in _get_pygments_extensions
    for lx in lexers.get_all_lexers():
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/pygments/lexers/__init__.py", line 53, in get_all_lexers
    for lexer in find_plugin_lexers():
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/pygments/plugin.py", line 53, in find_plugin_lexers
    yield entrypoint.load()
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2321, in load
    self.require(*args, **kwargs)
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2344, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/home/segtovichisv/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 783, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (prompt-toolkit 1.0.9 (/home/segtovichisv/anaconda3/lib/python3.6/site-packages), Requirement.parse('prompt-toolkit<2.0.0,>=1.0.15'))
```

## Versions

* Spyder version: 3.3.1 
* Python version: 3.6.3
* Qt version: 5.6.2
* PyQt5 version: 5.6
* Operating System: Linux 4.4.0-131-generic

### Dependencies

```
pyflakes >=0.6.0  :  1.5.0 (OK)
pycodestyle >=2.3 :  2.4.0 (OK)
pygments >=2.0    :  2.1.3 (OK)
sphinx >=0.6.6    :  1.5.6 (OK)
rope >=0.9.4      :  0.9.4-1 (OK)
jedi >=0.9.0      :  0.12.0 (OK)
psutil >=0.3      :  5.0.1 (OK)
nbconvert >=4.0   :  4.2.0 (OK)
pandas >=0.13.1   :  0.19.2 (OK)
numpy >=1.7       :  1.11.3 (OK)
sympy >=0.7.3     :  1.0 (OK)
cython >=0.21     :  0.25.2 (OK)
qtconsole >=4.2.0 :  4.2.1 (OK)
IPython >=4.0     :  6.4.0 (OK)
matplotlib >=2.0.0:  2.2.2 (OK)
pylint >=0.25     :  1.6.4 (OK)
```



Discussion:
manually solved making a `conda update prompt_toolkit`
Thanks for reporting. We'll fix this in our next release.

Resolving patch:
diff --git a/spyder/config/utils.py b/spyder/config/utils.py
--- a/spyder/config/utils.py
+++ b/spyder/config/utils.py
@@ -122,7 +122,10 @@ def get_edit_filetypes():
     if os.name == 'nt':
         supported_exts = []
     else:
-        supported_exts = _get_pygments_extensions()
+        try:
+            supported_exts = _get_pygments_extensions()
+        except Exception:
+            supported_exts = []
 
     # NOTE: Try to not add too much extensions to this list to not
     # make the filter look too big on Windows


Test patch: