Runtime Error when trying to launch Jupyter Notebook (Python) - python

I usually work with the Jupyter Notebook Interface when programming Python but recently I installed bioservices through pip (Bioservices) and when I tried to open the Jupyter Notebook I get the following RunTime error:
~$ jupyter notebook
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 60, in <module>
from .services.contents.manager import ContentsManager
File "/usr/local/lib/python2.7/dist-packages/notebook/services/contents/manager.py", line 16, in <module>
from nbformat import sign, validate, ValidationError
File "/usr/local/lib/python2.7/dist-packages/nbformat/__init__.py", line 33, in <module>
from .validator import validate, ValidationError
File "/usr/local/lib/python2.7/dist-packages/nbformat/validator.py", line 12, in <module>
from jsonschema import ValidationError
File "/usr/local/lib/python2.7/dist-packages/jsonschema/__init__.py", line 18, in <module>
from jsonschema.validators import (
File "/usr/local/lib/python2.7/dist-packages/jsonschema/validators.py", line 8, in <module>
import requests
File "/home/bioinfo/.local/lib/python2.7/site-packages/requests/__init__.py", line 74, in <module>
raise RuntimeError('Requests dependency \'chardet\' must be version >= 3.0.2, < 3.1.0!')
RuntimeError: Requests dependency 'chardet' must be version >= 3.0.2, < 3.1.0!
P.S: I uninstalled bioservices and it did not solve the error! Tried to reinstall chardet but it give the next output:
~$ pip install chardet==3.0.2
Collecting chardet==3.0.2
Using cached chardet-3.0.2-py2.py3-none-any.whl
Installing collected packages: chardet
Successfully installed chardet-2.3.0

This looks like a broken dependency. Have you tried installing the correct version of the chardet package, e.g.
pip install chardet==3.0.2
Of course here I'm assuming you have pip installed. Otherwise you're stuck with what your system ships. In that case, I would advise installing pip or any alternative way to control you python installation on a finer level.

Apparently you have a package named chardet required somewhere, but the version of this module is deprecated. Try to update chardet with pip upgrade chardet or uninstall and reinstall it.
$ pip uninstall chardet
$ pip install chardet

I have also same error. after trying all it doesn't work for me.
so I simply uninstall it:
pip uninstall jupyter
Then again install jupyter notebook
(it doesn't remove your installed library, simply uninstall jupyter) let's try

Related

Unable to Pip Install PyMeenus using local package [duplicate]

I setup a new Debian 10 (Buster) instance on AWS EC2, and was able to install a pip3 package that depended on netifaces, but when I came back to it the next day the package is breaking reporting an error in netifaces. If I try to run pip3 install netifaces I get the same error:
~$ pip3 install netifaces
Collecting netifaces
Using cached https://files.pythonhosted.org/packages/0d/18/fd6e9c71a35b67a73160ec80a49da63d1eed2d2055054cc2995714949132/netifaces-0.10.9.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 20, in <module>
from setuptools.dist import Distribution, Feature
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 35, in <module>
from setuptools.depends import Require
File "/usr/lib/python3/dist-packages/setuptools/depends.py", line 7, in <module>
from .py33compat import Bytecode
File "/usr/lib/python3/dist-packages/setuptools/py33compat.py", line 55, in <module>
unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
HTMLParser().unescape was removed in Python 3.9. Compare the code in Python 3.8 vs Python 3.9.
The error seems to be a bug in setuptools. Try to upgrade setuptools. Or use Python 3.8.
I was facing this issue in PyCharm 2018. Apart from upgrading setuptools as mentioned above, I also had to upgrade to PyCharm 2020.3.4 to solve this issue. Related bug on PyCharm issue tracker: https://youtrack.jetbrains.com/issue/PY-39579
Hope this helps someone avoid spending hours trying to debug this.
I had python3.6 and related packages through deb management.
Needed python3.9 for side project and the solution to fix pip and AttributeError: 'HTMLParser' object has no attribute 'unescape'
was to update pip for python3.9 locally for one user:
python3.9 -m pip install --upgrade pip
now installing python3.9 version of the pip-packages work:
python3.9 -m pip install --target=~/.local/lib/python3.9/site-packages numpy
Downgrading to any older python3 version is not the solution and most of the time upgrading setuptools won't fix the issue. The proper solution that worked for me to work with pip using python3.9 is the following on Ubuntu18:
locate /usr/lib/python3/dist-packages/setuptools/py33compact.py33
and change
# unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape) # comment out this line
unescape = getattr(html, 'unescape', None)
if unescape is None:
# HTMLParser.unescape is deprecated since Python 3.4, and will be removed
# from 3.9.
unescape = html_parser.HTMLParser().unescape

Can't install pip3 for python 3.9

I've tried everything, I've tried doing the following:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.9 get-pip.py
But that just gives me the following error:
root#ubuntu18:~# python3.9 get-pip.py
Traceback (most recent call last):
File "/root/get-pip.py", line 24184, in <module>
main()
File "/root/get-pip.py", line 139, in main
bootstrap(tmpdir=tmpdir)
File "/root/get-pip.py", line 120, in bootstrap
args = determine_pip_install_arguments()
File "/root/get-pip.py", line 65, in determine_pip_install_arguments
import setuptools # noqa
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 14, in <module>
from setuptools.dist import Distribution, Feature
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 24, in <module>
from setuptools.depends import Require
File "/usr/lib/python3/dist-packages/setuptools/depends.py", line 7, in <module>
from .py33compat import Bytecode
File "/usr/lib/python3/dist-packages/setuptools/py33compat.py", line 54, in <module>
unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
And i've sat hours trying different fixes, when i do pip3 --version it shows that its using python 3.6
And your thinking, why do i need to install it for python 3.9, well the py app im using only supports that and when i try to run it using python3.9 app.py it says that there is missing pip3 modules even though its installed.
I hope someone can tell me a fix, or what's causing the error.
Thanks.
This same thing happened to me, my installation wouldn’t compile correctly because a file in python wasn’t updating from a older version. Just reinstall python 3.9 and retry installing pip3 then it should work. It sucks to do but solves more issues down the road.
Try this command to upgrade setuptools
pip3 install --upgrade setuptools
If that doesnt work , try these
pip3 install --upgrade pip
pip3 install --upgrade distlib

How do I get my scikit-learn library to work on windows using pip package installer?

I am using the windows command prompt to install the scikit learn library using the command pip install -U scikit-learn. However, whenever I try to import it into my program I get an error stating that there is no module named 'sklearn'. Also, whenever I download the library using pip, for some reason, my pip package installer seems to break and pip is no longer recognized as a command on my cmd. I have numerous other modules which work perfectly fine so I don't see a reason as to why I can't get this specific library to work. I am still quite new to this kind of thing, so maybe I am missing something.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import sklearn
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn_init_.py", line 82, in
from .base import clone
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\base.py", line 17, in
from .utils import IS_32BIT
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils_init.py", line 20, in
from scipy.sparse import issparse
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse_init_.py", line 227, in
from .base import *
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse\base.py", line 4, in
from .sputils import (isdense, isscalarlike, isintlike,
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse\sputils.py", line 8, in
from scipy._lib._util import prod
ModuleNotFoundError: No module named 'scipy._lib._util'
Try to upgrade pip to newest version by python -m pip install --upgrade pip considering you are still using Windows. And then try to download sciKitLearn by pip install sklearn
This is how I had solved my problem but keep note that it was about a year ago
If all this doesn't work, try VirtualEnv.

Module six not found, although module six is installed

I cannot run jupyter lab as it complains about module six. Module six is already installed with conda. I even tried to install with pip too, but it says it is already installed and doesn't do anything. So, what to do here?
jupyter lab
Traceback (most recent call last):
File "c:\users\ilyas\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\ilyas\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\ilyas\Anaconda3\Scripts\jupyter-lab.EXE\__main__.py", line 5, in <module>
File "c:\users\ilyas\anaconda3\lib\site-packages\jupyterlab\labapp.py", line 11, in <module>
from jupyter_core.application import JupyterApp, base_aliases
File "c:\users\ilyas\anaconda3\lib\site-packages\jupyter_core\application.py", line 30, in <module>
from traitlets.config.application import Application, catch_config_error
File "c:\users\ilyas\anaconda3\lib\site-packages\traitlets\__init__.py", line 1, in <module>
from .traitlets import *
File "c:\users\ilyas\anaconda3\lib\site-packages\traitlets\traitlets.py", line 57, in <module>
import six
ModuleNotFoundError: No module named 'six'
I tried to remove with conda, and then re-install but that also did not work:
conda remove six
RemoveError: This operation will remove conda without replacing it with
another version of conda.
Install with pip:
pip install six
Requirement already satisfied: six in c:\users\ilyas\anaconda3\lib\site-packages (1.12.0)
python -m pip install six
Requirement already satisfied: six in c:\users\ilyas\anaconda3\lib\site-packages (1.12.0)
Environment:
Windows 10
python 3.7
jupyter-lab 1.0.0a3
six 1.12.0
you are installing six for Python 2, but trying to use it from Python 3.
install for Python 3 with:
python3 -m pip install six
Tried the following but still NOT solved:
I had to do this in the following error:
pip uninstall six
pip install six
Then I get the the ModuleNotFoundError: No module named 'jupyter_server' error.
So I install jupyter_server with conda, and now the jupyter lab is working.
conda install -c conda-forge jupyter_server
Even though the notebook is opening, I could not import packages. Checking the command prompt was showing the jupyterlab-manager was outdated. So, did the following:
jupyter labextension install #jupyter-widgets/jupyterlab-manager
Still, the notebook opens but cannot do anything with it.
few years late but I had the same problem. To add a little to what Corey was saying. I think you need to install it via Conda to use it in Conda (and hence Jupyter), i.e.
conda install six

Please help a newbie install NLTK on Mac OS 10.5.8

I'm completely new to programming. I've been trying various ways to install NLTK on my Mac (running OS 10.5.8), and none of them is working. Please help! Here's what I've done so far.
Since at first I didn't realize that newer versions of Python required OS 10.6 or higher, I first tried to install the latest versions of both Python 3 and Python 2, but this obviously didn't work. I then cottoned on and found an older installation (the filename is python-2.7.6-macosx10.3.dmg), which installed successfully.
I then tried to follow the instructions on this page, which I copy below:
Install Setuptools: http://pypi.python.org/pypi/setuptools
Install Pip: run sudo easy_install pip
Install Numpy (optional): run sudo pip install -U numpy
Install PyYAML and NLTK: run sudo pip install -U pyyaml nltk
Test installation: run python then type import nltk
Steps 1 and 2 worked fine, but when I try steps 3 and 4, I get an error. The error is the same whether I try step 3 or step 4:
unknown0021E9E0E476:~ Tom$ sudo pip install -U numpy
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module> load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2173, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1906, in loadentry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/__init__.py", line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/util.py", line 17, in <module>
from pip.vendor.distlib import version
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/vendor/distlib/version.py", line 13, in <module>
from .compat import string_types
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/vendor/distlib/compat.py", line 276
return b''
^
SyntaxError: invalid syntax
I then found a different set of instructions on this page. It first has you install Xcode and MacPorts, which I did (again finding older versions compatible with 10.5.8). I got through the next few steps successfully: installed python27, made it the system default (sudo port select --set python python27), and installed the dependencies py27-numpy, py27-yaml, and py27-scipy. However, I can't install one needed package, py27-matplotlib. Here's what happens when I try:
unknown0021E9E0E476:~ Tom$ sudo port install py27-matplotlib
---> Computing dependencies for py27-matplotlib
---> Dependencies to be installed: py27-pyobjc-cocoa py27-pyobjc py27-six py27-tkinter tk Xft2 tcl xorg-libXScrnSaver xorg-scrnsaverproto py27-tornado py27-backports-ssl_match_hostname py27-backports
---> Staging py27-pyobjc into destroot
Error: org.macports.destroot for port py27-pyobjc returned: command execution failed
Error: Failed to install py27-pyobjc
Please see the log file for port py27-pyobjc for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_python_py-pyobjc/py27-pyobjc/main.log
Error: The following dependencies were not installed: py27-pyobjc-cocoa py27-pyobjc py27-six py27-tkinter tk Xft2 tcl xorg-libXScrnSaver xorg-scrnsaverproto py27-tornado py27-backports-ssl_match_hostname py27-backports
To report a bug, follow the instructions in the guide:
http://guide.macports.org/#project.tickets
Error: Processing of port py27-matplotlib failed
Without this package, I can't go on to install NLTK.
I've also tried installing NLTK in PyCharm, but that didn't work either: see this question. I'm at my wits' end here, so any help would be much appreciated!
ETA: Problem solved! I downloaded the tar.gz file from https://pypi.python.org/pypi/nltk and followed the install instructions in the package, and now I can import NLTK in the Python shell. Is it possible that I was simply trying to install things while in the wrong directory? (I'd still like to use NLTK in PyCharm, so answers to that question will still be welcome.)
Try installing the scipy package which includes matplotlib and numpy, I was a TA on a course where we used numpy and matplotlib quite a lot and using the scipy package to install was a solution for a lot of people.
The individual binary and source packages are available from: scipy docs
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose

Categories