Repository: spyder-ide/spyder

Issue:
Spyder can't open a console because of problems with Beautiful Soup
## Description of your problem

Not sure if this is Conda or Spyder issue, but after the recent update of conda I can't open new ipython console. 

**What steps will reproduce the problem?**
1.  Install latest conda with :  conda update --all
2.  Observe that it updates to ipython 5.0
3. Open Spyder and create new ipython console

**What is the expected output? What do you see instead?**
An error ocurred while starting the kernel
Error in sitecustomize; set PYTHONVERBOSE for traceback:
AttributeError: module 'pkg_resources' has no attribute 'iter_entry_points'
Traceback (most recent call last):
File "/home/ilker/ILK/Anaconda3/lib/python3.5/site‑packages/spyderlib/widgets/externalshell/start_ipython_kernel.py", line 183, in 
from IPython.kernel.zmq.kernelapp import IPKernelApp
File "/home/ilker/ILK/Anaconda3/lib/python3.5/site‑packages/IPython/**init**.py", line 49, in 
from .terminal.embed import embed
File "/home/ilker/ILK/Anaconda3/lib/python3.5/site‑packages/IPython/terminal/embed.py", line 17, in 
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/home/ilker/ILK/Anaconda3/lib/python3.5/site‑packages/IPython/terminal/interactiveshell.py", line 84, in 
class TerminalInteractiveShell(InteractiveShell):
File "/home/ilker/ILK/Anaconda3/lib/python3.5/site‑packages/IPython/terminal/interactiveshell.py", line 128, in TerminalInteractiveShell
help="The name of a Pygments style to use for syntax highlighting: \n %s" % ', '.join(get_all_styles())
File "/home/ilker/ILK/Anaconda3/lib/python3.5/site‑packages/pygments/styles/**init**.py", line 76, in get_all_styles
for name, _ in find_plugin_styles():
File "/home/ilker/ILK/Anaconda3/lib/python3.5/site‑packages/pygments/plugin.py", line 66, in find_plugin_styles
for entrypoint in pkg_resources.iter_entry_points(STYLE_ENTRY_POINT):
AttributeError: module 'pkg_resources' has no attribute 'iter_entry_points'

**Please provide any additional information below**
The problem is with the new ipython version 5.0.  Downgrading ipython back to 4.2 solved my issue.
## Versions and main components
- Spyder Version: 2.3.9
- Python Version: ipython 5.0
- Operating system: opensuse
## Dependencies

Please go to the menu entry `Help > Optional Dependencies` (or
`Help > Dependencies`), press the button `Copy to clipboard`
and paste the contents below:



Discussion:
I also have this issue, but now Spyder will not even load.  the loading pop-up screen with the logo comes up for about 100ms, not enough time to read the error message.  When I run spyder.exe, I get this:

Traceback (most recent call last):
  File "C:\Anaconda\Scripts\spyder-script.py", line 2, in <module>
    start_app.main()
  File "C:\Anaconda\lib\site-packages\spyderlib\start_app.py", line 114, in main

```
from spyderlib import spyder
```

  File "C:\Anaconda\lib\site-packages\spyderlib\spyder.py", line 155, in <module

> ```
> from spyderlib.utils.environ import WinUserEnvDialog
> ```
> 
>   File "C:\Anaconda\lib\site-packages\spyderlib\utils\environ.py", line 17, in <
> module>
>     from spyderlib.widgets.dicteditor import DictEditor
>   File "C:\Anaconda\lib\site-packages\spyderlib\widgets\dicteditor.py", line 39,
>  in <module>
>     from spyderlib.widgets.dicteditorutils import (sort_against, get_size,
>   File "C:\Anaconda\lib\site-packages\spyderlib\widgets\dicteditorutils.py", lin
> e 78, in <module>
>     import bs4
>   File "C:\Anaconda\lib\site-packages\bs4__init__.py", line 30, in <module>
>     from .builder import builder_registry, ParserRejectedMarkup
>   File "C:\Anaconda\lib\site-packages\bs4\builder__init__.py", line 311, in <mo
> dule>
>     from . import _html5lib
>   File "C:\Anaconda\lib\site-packages\bs4\builder_html5lib.py", line 57, in <mo
> dule>
>     class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
> AttributeError: 'module' object has no attribute '_base'

Spyder version: 2.3.9
IPython version: 5.0.0
Python version: 2.7.12

It works fine on my laptop, the only difference seems to be that my laptop runs Python 2.7.11.

It looks like a conda issue, no @ccordoba12 ?

I cannot pull up an IPython console, either.  

Traceback (most recent call last):
  File "c:\anaconda\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\anaconda\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Anaconda\pkgs\ipython-5.0.0-py27_0\Scripts\ipython.exe__main__.py",
line 5, in <module>
ImportError: No module named IPython

Yes, it seems you have a broken installation now. Please reinstall Anaconda and report again.

I was able to get IPython to load again using `conda install -f IPython` found here: http://conda.pydata.org/docs/troubleshooting.html

So, I was unable to install or update this bs4 package.  It appears to be Beautiful Soup.  The **init**.py file states lxml and/or html5lib be installed.  After installing html5lib, Spyder loads up.

This appears to be a dependency issue.  The new version of spyder should note this dependency on install!

We don't depend on beautifulsoup or html5lib, so this is really a dependencies problem with Anaconda.

I'm glad you were able to find and solve your problem ;-)

@ccordoba12  I wouldn't be so quick to close this.  It look like @ilkerhk still has an issue.

I also demonstrated that the spyder package imports bs4.  So it appears that spyder does use Beautiful Soup.

File "C:\Anaconda\lib\site-packages\spyderlib\widgets\dicteditorutils.py", lin
e 78, in
import bs4

It's true we import `bs4` but it's a conditional import, we don't depend directly on it.

So although this is clearly an installation issue, we can add a bit of code to address it ;-)

I tried with and without beautifulsoup and html5lib, but didn't see any effect.  I still can't run with a different error (see below). But downgrading back to iPython 4.2.0 + Spyder2  works for me.  I am OK with those. 

Thanks all for the replies. 
best,

P.S.  I've just tried fresh conda environment. After the install everything works fine (Spyder2 and iPython 4.2.0 ).  If I upgrade to Spyder 3, I got the below error. I upgrade to iPython 5.0 still got below error.  

An error ocurred while starting the kernel
Either:
Your IPython frontend and kernel versions are incompatible or
You don't have IPython installed in your external interpreter.
In any case, we're sorry but we can't create a console for you.

I realized I have other issue(s) with the setup. I installed all fresh but still getting error. So please ignore the error I mentioned in the last comment. 
I will open a new issue.

The error in the first comment (which is about IPython 5 and Pygments and has nothing to do with beautifulsoup) has also been reported in issue #3309.


Resolving patch:
diff --git a/spyderlib/widgets/variableexplorer/utils.py b/spyderlib/widgets/variableexplorer/utils.py
--- a/spyderlib/widgets/variableexplorer/utils.py
+++ b/spyderlib/widgets/variableexplorer/utils.py
@@ -98,7 +98,7 @@ def get_numpy_dtype(obj):
 try:
     import bs4
     NavigableString = bs4.element.NavigableString
-except ImportError:
+except (ImportError, AttributeError):
     NavigableString = FakeObject  # analysis:ignore
 
 


Test patch: