Module six not found, although module six is installed - python

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

Related

cv2 not work after install mediapipe library

I want to make handtracker program using python but the tutorial tell me to install mediapipe library, then I installed it. Before that it's okay using cv2 to stream my camera, but after installing mediapipe, the cv2 doesn't work
here the message :
>>>import cv2
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
File "C:\Users\windows\AppData\Local\Programs\Python\Python39\lib\site-packages\cv2\__init__.py", line 181, in <module>
bootstrap()
File "C:\Users\windows\AppData\Local\Programs\Python\Python39\lib\site-packages\cv2\__init__.py", line 175, in bootstrap
if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
File "C:\Users\windows\AppData\Local\Programs\Python\Python39\lib\site-packages\cv2\__init__.py", line 28, in __load_extra_py_code_for_module
py_module = importlib.import_module(module_name)
File "C:\Users\windows\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\windows\AppData\Local\Programs\Python\Python39\lib\site-packages\cv2\gapi\__init__.py", line 290, in <module>
cv.gapi.wip.GStreamerPipeline = cv.gapi_wip_gst_GStreamerPipeline
AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import) ```
I tried to install opencv again but always get this message :
Requirement already satisfied: numpy>=1.19.3 in c:\users\windows\appdata\local\programs\python\python39\lib\site-packages (from opencv-python) (1.21.1)
but the problem still there. How do I fix it?
Edited : this is my pip list
C:\Users\windows>pip list
Package Version
--------------------- --------
absl-py 1.1.0
attrs 21.4.0
cycler 0.11.0
fonttools 4.33.3
kiwisolver 1.4.2
matplotlib 3.5.2
mediapipe 0.8.10
numpy 1.21.1
opencv-contrib-python 4.6.0.66
opencv-python 4.5.3.56
packaging 21.3
Pillow 8.3.1
pip 22.1.2
protobuf 4.21.1
pygame 2.1.2
pyparsing 3.0.9
python-dateutil 2.8.2
pyzbar 0.1.8
setuptools 56.0.0
six 1.16.0
I have the same situation like above
you can try it:
pip install "opencv-python-headless<4.3"
This command has successfully resolved this situation
Reference:https://github.com/Rudrabha/Wav2Lip/issues/387
In any version(ex: 4.6.0.66), when you install any 2 of 3 packages: opencv-contrib-python, opencv-python-headless, opencv-python, make sure they have the same version. I also got the same error, I found out their versions are different. Then a synchronous update solved the problem.
I have similar problem, and I only have opencv-python installed. The problem is solved by installing opencv-python-headless.
My problem is more complicate than that. Actually the opencv-python is already installed in "root", but when I login as another user (dev), I get the problem as OP.
I can install opencv-python-headless or opencv-contrib-python manually, then the system will work. But if I install them in "root", I sill have the same problem.
So the final solution I use is to reinstall opencv-python in my user environment (dev):
pip3 install --upgrade --force-reinstall opencv-python
I fix such a problem using the following commands.
pip uninstall opencv-contrib-python
pip install opencv-contrib-python
the following solution
pip install "opencv-python-headless<4.3"
fixed the error below when building OpenCV from source!
import cv2
Traceback (most recent call last):
File "", line 1, in
File "C:\ProgramData\Anaconda3\lib\site-packages\cv2_init_.py", line 181, in
bootstrap()
File "C:\ProgramData\Anaconda3\lib\site-packages\cv2_init_.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "C:\ProgramData\Anaconda3\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing cv2: The specified module could not be found.

Pip broken after upgrade. Cannot unsinstall or upgrade Pip or Python

I recently had tried to run a pip command and noticed my pip version was considerably out of date so upgraded it. This seems to have completely broken my pip install and I cannot figure out how to reset it.
$ pip3 --version
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)
You are using pip version 8.1.1, however version 22.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ pip3 install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/f3/77/23152f90de45957b59591c34dcb39b78194eb67d088d4f8799e9aa9726c4/pip-22.1-py3-none-any.whl (2.1MB)
100% |████████████████████████████████| 2.2MB 505kB/s
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 22.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 11, in <module>
sys.exit(main())
File "/home/myname/.local/lib/python3.5/site-packages/pip/__init__.py", line 11, in main
from pip._internal.utils.entrypoints import _wrapper
File "/home/myname/.local/lib/python3.5/site-packages/pip/_internal/utils/entrypoints.py", line 12
f"pip{sys.version_info.major}",
^
SyntaxError: invalid syntax
This seems to come from this: https://github.com/pypa/pip/issues/9526
I can't seem to uninstall pip:
$ python3 -m pip uninstall pip
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/myname/.local/lib/python3.5/site-packages/pip/__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "/home/myname/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 57
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
I'm on python3.5 and can't seem to upgrade that either:
$ sudo apt-get install python3.6
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3.6
E: Couldn't find any package by glob 'python3.6'
E: Couldn't find any package by regex 'python3.6'
I'm found a number of stackoverflow answers suggesting to use alternative repositories but they're not working either.
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3.6
E: Couldn't find any package by glob 'python3.6'
E: Couldn't find any package by regex 'python3.6'
I've tried 3.6, 3.7, 3.8, 3.9 and 3.10 with the same results.
I've also found some stack overflow answers suggesting to edit /usr/bin/pip3
Originally it looks like this:
from pip import main
if __name__ == '__main__':
sys.exit(main())
I've tried this:
from pip._internal import __main__
if __name__ == '__main__':
sys.exit(main())
and this:
I've tried this:
from pip._internal import __main__
if __name__ == '__main__':
sys.exit(__main__._main())
But neither have resolved the issue.
To be sure i'm not messed up with a local version i've tried all of the above using /usr/bin/pip3 --version rather than just pip3 --version with the same results.
Now i'm at a bit of a loss how to get a working version of Python and Pip.
Suggestion from question:
$ sudo python3.5 -m easy_install pip
Searching for pip
Best match: pip 22.1
Adding pip 22.1 to easy-install.pth file
Installing pip3 script to /usr/local/bin
Installing pip3.10 script to /usr/local/bin
Installing pip script to /usr/local/bin
Using /home/myname/.local/lib/python3.5/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
$ ls -lh /usr/local/bin/*pip*
-rwxr-xr-x 1 root root 361 May 12 19:49 /usr/local/bin/pip
-rwxr-xr-x 1 root root 363 May 12 19:49 /usr/local/bin/pip3
-rwxr-xr-x 1 root root 369 May 12 19:49 /usr/local/bin/pip3.10
All 3 return the same thing:
$ /usr/local/bin/pip --version
$ /usr/local/bin/pip3 --version
$ /usr/local/bin/pip3.10 --version
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module>
load_entry_point('pip==22.1', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2291, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2297, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/home/myname/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 57
sys.stderr.write(f"ERROR: {exc}")
^
I've now installed Python3.6 using "method two" from here: https://askubuntu.com/questions/1152640/apt-install-doesnt-install-python3-6 i.e. manual install
I've then upgraded pip using:
sudo python3.6 -m pip install pip --upgrade
Now pip --version and pip3 --version return an error but directly accessing the bin works:
$ /usr/local/bin/pip --version
pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
The aliases are currently pointing to:
$ which pip
/home/sortitoutsi/.local/bin/pip
$ which pip3
/home/sortitoutsi/.local/bin/pip3
It seems that other things are now broken, such as aws.
$ aws --help
Traceback (most recent call last):
File "/usr/local/bin/aws", line 19, in <module>
import awscli.clidriver
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 17, in <module>
import botocore.session
File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 29, in <module>
import botocore.configloader
File "/usr/local/lib/python2.7/dist-packages/botocore/configloader.py", line 19, in <module>
from botocore.compat import six
File "/usr/local/lib/python2.7/dist-packages/botocore/compat.py", line 26, in <module>
from dateutil.tz import tzlocal
File "/usr/local/lib/python2.7/dist-packages/dateutil/tz/__init__.py", line 1, in <module>
from .tz import *
File "/usr/local/lib/python2.7/dist-packages/dateutil/tz/tz.py", line 16, in <module>
from six import string_types, PY3
ImportError: No module named six
Simply reinstalling aws sudo python -m pip install awscli seemed to have fixed the above. I'm guessing a sudo apt-get update at some point forced an upgrade of awscli after finding an updated Python installation.
Do not try and install Python versions and packages (from another ppa) that are not supported by your OS. Your system may break.
Your attempted Pip installation is, luckily, in a local directory: $HOME/.local/. Check if there is anything else installed in $HOME/.local/bin/ and $HOME/.local/lib/python3.5/site-packages/. If nothing (or nothing that seems important), rename that directory:
mv ~/.local ~/.local_aside
Now, you should have the system Pip back again.
You may lose some other packages that you installed earlier (which would now be in ~/.local_aside, but possibly, you can reinstall those. Either with a system packages (e.g., python3-numpy), or again with pip3 install numpy and the like. Though pip may have trouble finding a correct NumPy version, since Python 3.5 is not supported anymore (the system package should be fine).
If you want to use a more recent version of Python, install a local (user-only) one. My preferred way of doing that is to use pyenv, which requires some set up (installing the necessary build packages). If you use pyenv, carefully read the installation instructions for your case. Once you get it going, you can quickly install any version of Python, and between minor versions, they won't even get in the way (that is, python3.9 -m pip install numpy will be a separate installation from python3.10 -m pip install numpy, and both can happily live next to each other if so wanted).
But don't use sudo and install it as a root: your system will get confused and may break.
Another alternative is Conda, in the form (my preference) of miniconda3. Conda can and will also install C library dependencies, and actively tries to resolve version conflicts between Python packages (in case you have to install a lot of packages). Again, browse the manual to get going, but it's relatively straightforward to use, and doesn't get in the way of your OS.

conda update causes ImportError: No module named tqdm

Whenever I try to update anything using conda, I get an error: ImportError: No module named tqdm. Here's the full traceback:
$ conda update conda
Traceback (most recent call last):
File "/Users/user/anaconda2/bin/conda", line 13, in <module>
sys.exit(main())
File "/Users/user/anaconda2/lib/python2.7/site-packages/conda/cli/main.py", line 150, in main
return conda_exception_handler(_main, *args, **kwargs)
File "/Users/user/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1335, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "/Users/user/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1046, in __call__
return self.handle_exception(exc_val, exc_tb)
File "/Users/user/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1090, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "/Users/user/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1101, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "/Users/user/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1171, in print_unexpected_error_report
from .cli.main_info import get_env_vars_str, get_main_info_str
File "/Users/user/anaconda2/lib/python2.7/site-packages/conda/cli/main_info.py", line 19, in <module>
from ..core.index import _supplement_index_with_system
File "/Users/user/anaconda2/lib/python2.7/site-packages/conda/core/index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "/Users/user/anaconda2/lib/python2.7/site-packages/conda/core/package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
File "/Users/user/anaconda2/lib/python2.7/site-packages/conda_package_handling/api.py", line 5, in <module>
import tqdm
ImportError: No module named tqdm
However, when I try to install tqdm with pip, it says it is already installed:
$ pip install tqdm
Requirement already satisfied: tqdm in /usr/local/lib/python2.7/site-packages (4.32.2)
I am using Python 2.7 on MacOS Mojave with no virtual environments. How can I fix conda?
EDIT:
I also tried: python -m pip install tqdm but it says requirement already satisfied.
Then I tried: /Users/user/anaconda2/bin/python -m pip install tqdm but it also says requirement already satisfied: Requirement already satisfied: tqdm in ./anaconda2/lib/python2.7/site-packages (4.31.1)
I ended up removing and reinstalling anaconda, which fixed the problem.
If you cannot use conda to install tqdm, something is seriously messed up.
In the best of cases, it's only about environment variables. Are you setting PYTHONPATH or similar? That could interfere with conda finding its own packages.
Check your environment variables, don't set anything Python.
Execute conda activate base.
Check that python now is the one from the conda base environment.
Call conda install.
In the worst of cases, you somehow uninstalled or broke a package that conda needs. In this case, re-install Miniconda from scratch in a different directory. You should use Miniconda3 (or Anaconda3) this time, as Python 2 is only half a year away from its end of life.
Afaik, conda is able to mange existing environments from a previous installation, but I've never tried to use that feature.
If you haven't been using conda environments, but installed everything into the conda base environment, and that environment is messed up, I have no idea how to recover. You should always create custom conda environments for your projects.
for ubuntu 18.04
i faced the same issue on jupyter notebook, however the current apt install builds the 4.19 as latest which was bugged out for me.
Here are my steps for the solution:
Download the desired newer version
http://old-releases.ubuntu.com/ubuntu/pool/universe/t/tqdm/
cd to deb file location
sudo dpkg -i <filename.deb>

Runtime Error when trying to launch Jupyter Notebook (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

Can't find "six", but it's installed

I have six installed (even reinstalled it).
$ pip show six
---
Name: six
Version: 1.7.3
Location: /usr/lib/python2.6/site-packages
Requires:
But when I try to run csvcut, it can't find it.
$ csvcut -n monster.csv
Traceback (most recent call last):
File "/usr/bin/csvcut", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: six>=1.6.1
Here's the relevant but of csvcut:
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'csvkit==0.8.0','console_scripts','csvcut'
__requires__ = 'csvkit==0.8.0'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('csvkit==0.8.0', 'console_scripts', 'csvcut')()
)
This is on CentOS.
Uninstalling and reinstalling six using pip didn't work
sudo pip uninstall six
sudo pip install six
However, I was able to solve the problem using easy_install:
easy_install --upgrade six
Reason for this is when you install Six using PIP the location of the Six library isnt added to Pythons Path so when trying to use the commands, python cant find them. Installing with Easy_Install doesn't have this problem, when it is installing six it automatically updates the python path variable so python can find the library.
Installing by Easy_Install as answered before resolves this but you can alternatively add the location to the python path variable.
I came across the same problem today, reinstalling with pip did not work and i can not do it with easy_install as it a custom package
the solution was to point the PYTHONPATH variable to the site-packages that contains the package
export PYTHONPATH=$PYTHONPATH:/path/to/sites-package
you will face this problem if you work with virtual env

Categories