jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.41k stars 4.76k forks source link

'import fbprophet' fails in ipython while it's ok in notebook #3213

Open cndaimin opened 6 years ago

cndaimin commented 6 years ago
[root@0b56f3e010c5 /root]
#/root/anaconda3/bin/ipython
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:53:06)
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import fbprophet
   ...: fbprophet.__version__
   ...:
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-382e3dfa0c79> in <module>()
----> 1 import fbprophet
      2 fbprophet.__version__

/root/anaconda3/lib/python3.5/site-packages/fbprophet/__init__.py in <module>()
      6 # of patent rights can be found in the PATENTS file in the same directory.
      7
----> 8 from fbprophet.forecaster import Prophet
      9
     10 __version__ = '0.2.1'

/root/anaconda3/lib/python3.5/site-packages/fbprophet/forecaster.py in <module>()
     18 logger = logging.getLogger(__name__)
     19
---> 20 from matplotlib import pyplot as plt
     21 from matplotlib.dates import MonthLocator, num2date
     22 from matplotlib.ticker import FuncFormatter

/root/anaconda3/lib/python3.5/site-packages/matplotlib/pyplot.py in <module>()
    114 ## Global ##
    115
--> 116 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
    117
    118 _IP_REGISTERED = None

/root/anaconda3/lib/python3.5/site-packages/matplotlib/backends/__init__.py in pylab_setup(name)
     58     # imports. 0 means only perform absolute imports.
     59     backend_mod = __import__(backend_name, globals(), locals(),
---> 60                              [backend_name], 0)
     61
     62     # Things we pull in from all backends

/root/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_tkagg.py in <module>()
      4
      5 import six
----> 6 from six.moves import tkinter as Tk
      7 from six.moves import tkinter_filedialog as FileDialog
      8

/root/anaconda3/lib/python3.5/site-packages/six.py in __get__(self, obj, tp)
     90
     91     def __get__(self, obj, tp):
---> 92         result = self._resolve()
     93         setattr(obj, self.name, result)  # Invokes __set__.
     94         try:

/root/anaconda3/lib/python3.5/site-packages/six.py in _resolve(self)
    113
    114     def _resolve(self):
--> 115         return _import_module(self.mod)
    116
    117     def __getattr__(self, attr):

/root/anaconda3/lib/python3.5/site-packages/six.py in _import_module(name)
     80 def _import_module(name):
     81     """Import module, returning the module after the last dot."""
---> 82     __import__(name)
     83     return sys.modules[name]
     84

/root/anaconda3/lib/python3.5/tkinter/__init__.py in <module>()
     33 import sys
     34
---> 35 import _tkinter # If this fails your Python may not be configured for Tk
     36 TclError = _tkinter.TclError
     37 from tkinter.constants import *

ImportError: libXdmcp.so.6: cannot open shared object file: No such file or directory

In [2]:

image

It's very strange 'cause they should not have any difference.

OrangeBot commented 6 years ago

Hi, One clue i see here is that you have 'six' module in your traceback. While i'm not completely aware of situation, PyCharm warns me for one of my projects that it includes 'six' package and there might be compatibility issues..

The difference between notebook and ipython is, for example, Display variable. And as it also has something to do with matplotlib - that might be the reason.

# works for me
ipython
Python 3.5.4 |Anaconda custom (64-bit)| (default, Nov 20 2017, 18:44:38) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import fbprophet

In [2]: