plotly cannot import name exceptions - python

I know this question has been asked before but there are very few solutions given and I don't understand the ones that are provided.
I'm trying to import my module packages and I receive the error below. The strange thing is this was all working 2 days ago and I haven't really done anything since with it so I can't understand why this is now appearing.
import plotly.offline as pyo
from plotly.graph_objs import *
from plotly import tools
import plotly.plotly as py
import pandas as pd
import math as m
pyo.offline.init_notebook_mode()
this returns the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-f7b4615963aa> in <module>()
----> 1 import plotly.offline as pyo
2 from plotly.graph_objs import *
3 from plotly import tools
4 import plotly.plotly as py
5 import pandas as pd
C:\Users\Lewis\Anaconda3\Lib\site-packages\plotly\plotly\__init__.py in <module>()
8
9 """
---> 10 from . plotly import (
11 sign_in,
12 update_plot_options,
C:\Users\Lewis\Anaconda3\Lib\site-packages\plotly\plotly\plotly.py in <module>()
28 from requests.compat import json as _json
29
---> 30 from plotly import exceptions, files, session, tools, utils
31 from plotly.api import v1, v2
32 from plotly.plotly import chunked_requests
ImportError: cannot import name 'exceptions'
I've tried updating Plotly but this didn't do anything either. Could this be because I installed Jupyter notebook with my Anaconda installation, and my Lib\site-packages directory is within the Anaconda3 dir? Can't imagine this would be the cause but I can't think of much else. Any ideas?
[edit]
import sys
sys.path
['',
'C:\\Users\\Lewis\\Anaconda3\\Lib\\site-packages\\plotly',
'C:\\Users\\Lewis\\Anaconda3\\python36.zip',
'C:\\Users\\Lewis\\Anaconda3\\DLLs',
'C:\\Users\\Lewis\\Anaconda3\\lib',
'C:\\Users\\Lewis\\Anaconda3',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\Sphinx-1.5.6-py3.6.egg',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\Pythonwin',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\setuptools-27.2.0-py3.6.egg',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\Lewis\\.ipython']

in my case, after doing the upgrade like #Max above suggested, restarting the kernel finally fixed the problem

pip install --upgrade plotly
run the above command. it will work

Related

Signal Plotting with Jupyter Notebook

I have been trying to plot a certain signal on python but it keeps giving me an error message I don't know how to solve it
from matplotlib import pyplot as plt
from matplotlib import style
import mysignals as Sig
style.use('ggplot')
style.use('dark_background')
f,pltr_arr=plt.subplots(3,sharex=True)
pltr_arr[0].plot(sig.lnputSignal_1KHz_15kHz,color='magenta')
pltr_arr[0].set_title('subplot 1',color='magenta')
pltr_arr[1].plot(sig.InputSignal_1kHz_15kHz,color='yellow')
pltr_arr[1].set_title('Subplot 1', color='yellow')
pltr_arr[2].plot(sig.InputSignal_1kHz_15lkHz,color='green')
pltr_arr[2].set_title('Subplot 1',color='green')
above is the code of what I tried and below is the error message
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_9776\3731026071.py in
1 from matplotlib import pyplot as plt
2 from matplotlib import style
----> 3 import mysignals as Sig
4
5 style.use('ggplot')
ModuleNotFoundError: No module named 'mysignals'
Your error is ModuleNotFoundError: No module named 'mysignals'.
This error occurred since there is no python module named mysignals.py in the same directory or in installed through pip (see pip list).
See this for detailed instructions on how to import local files

Why is the Object Detection Demo of jupyter showing me that it cannot import tensorflow?

I am following this tensorflow tutorial https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#protobuf-installation-compilation and I am facing some problems when testing the installation.
I installed everything except the COCO API in the tutorial and I am running the object detection demo in jupyter right now. For some reason, I get an error inside the notebook which tells me that there is "No module named 'tensorflow'". Can I still click on Run All or does this error has to be fixed?
Thanks! :)
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from distutils.version import StrictVersion
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops
if StrictVersion(tf.__version__) < StrictVersion('1.12.0'):
raise ImportError('Please upgrade your TensorFlow installation to v1.12.*.')
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-34f5cdda911a> in <module>
4 import sys
5 import tarfile
----> 6 import tensorflow as tf
7 import zipfile
8
ModuleNotFoundError: No module named 'tensorflow'
Okay, for some reasons, I get this error now:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-34f5cdda911a> in <module>
10 from collections import defaultdict
11 from io import StringIO
---> 12 from matplotlib import pyplot as plt
13 from PIL import Image
14
ModuleNotFoundError: No module named 'matplotlib'
You might be facing the problem of a double version of Python installed on your computer. Jupyter is trying to compile the Tensorflow tutorial file but with the wrong kernel (which should be Python 3).
The same happened to me when trying to run ipynb files in which Tensorflow was included.
So I would first recommend you to do the following:
Check the output of this command in your command line:
jupyter kernelspec list
Then it should output something similar to this: (in case of Windows OS)
python3 c:\python 3.6.8\share\jupyter\kernels\python3
If you find "python2" or any other type of version, you should remove it manually or try by using the command :
jupyter kernelspec remove python_wrong_version
Finally, if the problem is still there you can also check the link https://github.com/jupyter/notebook/issues/397 for further discussions.

ImportError: No module named utils_datagen

I am trying to run Martin Gorner's GoogleCloudPlatform/tensorflow-without-a-phd 00_RNN_predictions_playground.ipynb and get an ImportError for both import utils_datagen and import utils_display.
I get the same error running tensorflow/tensorflow Python 2 and Jupiter/tensorflow-notebook running Python 3. I am running macOS Sierra 10.13.3 and Docker Client: Version: 18.03.1-ce
How do I access utils_datagen or work around it?
Thanks
Lew
import numpy as np
import utils_datagen
import utils_display
from matplotlib import pyplot as plt
import tensorflow as tf
print("Tensorflow version: " + tf.__version__)
print("Hello World and Lew 30 May")
And get:
ImportError Traceback (most recent call last)
<ipython-input-2-0f00155f1447> in <module>()
1 import numpy as np
----> 2 import utils_datagen
3 import utils_display
4 from matplotlib import pyplot as plt
5 import tensorflow as tf
ImportError: No module named utils_datagen
Solved by comment from #Y. Luo. In trying to simplify my file string, I only partially cloned the Gorner GitHub file into my host file and missed the utils_datagen file. Now python can find it.
Close this thread.

ImportError: No module named request when importing BeakerX into Jupyter

I am trying to import beakerx into my jupyter environment like so:
from beakerx import *
However, I get the following error:
ImportError Traceback (most recent call last)
<ipython-input-19-4c368a35c7cf> in <module>()
----> 1 from beakerx import *
/Users/vivaksoni1/venv/lib/python2.7/site-packages/beakerx/__init__.py in <module>()
13 # limitations under the License.
14
---> 15 from .runtime import BeakerX
16 from .plot import *
17 from .easyform import *
/Users/vivaksoni1/venv/lib/python2.7/site-packages/beakerx/runtime.py in <module>()
16
17 import os, json, pandas, numpy
---> 18 import urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse, IPython, datetime, calendar, math, traceback, time
19 from traitlets import Unicode
20
ImportError: No module named request
I am not sure what this error means? Also, it seems to be looking into python2.7 directories even though this is a python 3 script? I installed beakerx using: pip3 install beakerx and can see the files in the right folder within the right folder:
anaconda3/pkgs/beakerx-0.12.2-py36_2/lib/python3.6/site-packages/beakerx
This seems to be how every other module is stored but I cannot get it working for some reason. Can anyone help?

Jupyter (IPython) notebook numpy/pandas/matplotlib error (FreeBSD)

I am trying to set up a Jupyter notebook server at home. It has taken me a long time, but I have build and installed Python 3.4 and all the required packages from FreeBSD ports successfully. The notebook server is up and running fine, except every time when I try to import numpy:
In[1]: import numpy
The following errors occur:
ImportError Traceback (most recent call last)
<ipython-input-1-5a0bd626bb1d> in <module>()
----> 1 import numpy
/usr/local/lib/python3.4/site-packages/numpy/__init__.py in <module>()
178 return loader(*packages, **options)
179
--> 180 from . import add_newdocs
181 __all__ = ['add_newdocs',
182 'ModuleDeprecationWarning',
/usr/local/lib/python3.4/site-packages/numpy/add_newdocs.py in <module>()
11 from __future__ import division, absolute_import, print_function
12
---> 13 from numpy.lib import add_newdoc
14
15 ###############################################################################
/usr/local/lib/python3.4/site-packages/numpy/lib/__init__.py in <module>()
6 from numpy.version import version as __version__
7
----> 8 from .type_check import *
9 from .index_tricks import *
10 from .function_base import *
/usr/local/lib/python3.4/site-packages/numpy/lib/type_check.py in <module>()
9 'common_type']
10
---> 11 import numpy.core.numeric as _nx
12 from numpy.core.numeric import asarray, asanyarray, array, isnan, \
13 obj2sctype, zeros
/usr/local/lib/python3.4/site-packages/numpy/core/__init__.py in <module>()
12 os.environ[envkey] = '1'
13 env_added.append(envkey)
---> 14 from . import multiarray
15 for envkey in env_added:
16 del os.environ[envkey]
ImportError: /lib/libgcc_s.so.1: version GCC_4.6.0 required by /usr/local/lib/gcc48/libgfortran.so.3 not found
The error messages for importing pandas and matplotlib are different, but I suspect that has something to do with this numpy import error.
Strangely, all 3 packages work fine in Python and IPython consoles with no problems at all!
I have googled and made the following attempts:
delete and reinstall numpy -> no change
append numpy directory to sys.path -> no change
install a lot of other external packages just to see if it's only related to numpy -> they are all working fine in both consoles and notebook, except scipy giving some error related to numpy
Thank you for your help!
My gcc is version 4.2.1.
I have fixed this by setting the LD_LBRARY_PATH to /usr/local/lib/gcc48. gcc48 is already installed in my system.
To avoid setting the path every time, I've added the following line to /.cshrc:
setenv LD_LIBRARY_PATH /usr/local/lib/gcc48
edit:
This won't work is you want to start the notebook server automatically by adding to crontab:
#reboot /usr/local/bin/jupyter-notebook
the same error appears when trying to import numpy and modules depending on numpy
I fixed this by making a copy of /usr/local/bin/jupyter-notebook and added the following lines:
import sys
import re
----------------- add these 2 lines below --------------
import os
os.environ['LD_LIBRARY_PATH'] = '/usr/local/lib/gcc48'
....
Add the new file to crontab instead of jupyter-notebook.
The issue is not with your python modules. The error message at the bottom, where it says ImportError: /lib/libgcc_s.so.1: version GCC_4.6.0 required by /usr/local/lib/gcc48/libgfortran.so.3 not found indicates that it's a dependency error with the Fortran library. Apparently it wants gcc 4.6 or higher, and apparently you have a lower version installed. Not being familiar with Python libraries or your setup, my guess is that it could be an issue with /usr/ports/devel/py-fortran. I would recommend checking the gcc version on your machine with gcc -v and whatever fortran-related ports you have installed with pkg info and then take it from there.

Categories