Anaconda2: cannot import name md5 - anaconda

I just did a clean install of anaconda2 and conda always throws this error:
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/niid/anaconda2/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
Traceback (most recent call last):
File "/home/niid/.bin/conda", line 11, in <module>
sys.exit(main())
File "/home/niid/anaconda2/lib/python2.7/site-packages/conda/cli/main.py", line 182, in main
return conda_exception_handler(_main, *args)
File "/home/niid/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 644, in conda_exception_handler
return handle_exception(e)
File "/home/niid/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 634, in handle_exception print_unexpected_error_message(e)
File "/home/niid/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 596, in print_unexpected_error_message
stderrlogger.info(get_main_info_str(get_info_dict()))
File "/home/niid/anaconda2/lib/python2.7/site-packages/conda/cli/main_info.py", line 162, in get_info_dict
from ..connection import user_agent
File "/home/niid/anaconda2/lib/python2.7/site-packages/conda/connection.py", line 12, in <module>
from requests import Session, __version__ as REQUESTS_VERSION
File "/home/niid/anaconda2/lib/python2.7/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/home/niid/anaconda2/lib/python2.7/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/home/niid/anaconda2/lib/python2.7/site-packages/urllib3/connectionpool.py", line 29, in <module>
from .connection import (
File "/home/niid/anaconda2/lib/python2.7/site-packages/urllib3/connection.py", line 39, in <module>
from .util.ssl_ import (
File "/home/niid/anaconda2/lib/python2.7/site-packages/urllib3/util/__init__.py", line 6, in <module>
from .ssl_ import (
File "/home/niid/anaconda2/lib/python2.7/site-packages/urllib3/util/ssl_.py", line 7, in <module>
from hashlib import md5, sha1, sha256
ImportError: cannot import name md5
The first instance of this error happens when conda is called during installation.
It can be reproduced by manually calling conda or by calling
$HOME/anaconda2/python -c "import md5"
I was unable to find any fixes related to this problem so far. It is very strange since I just did
rm -rf $HOME/anaconda2
and then did a clean reinstall.
EDIT:
The problem seems to be only with Anaconda 5. I reinstalled Anaconda 4.4.0 and the problem does not occur. I will try the anaconda forums.

I was having the exact same problem, I believe Anaconda got it fixed in their latest release 25 Oct 2017 (Anaconda 5.0.1).
Now it worked for me.
https://www.anaconda.com/download/#linux

Related

PermissionError: [WinError 5] Access is denied in anaconda spyder for tesseract.exe

runfile('E:/python/tensorflow.py', wdir='E:/python')
Traceback (most recent call last):
File "<ipython-input-1-c970ef5c8f56>", line 1, in <module>
runfile('E:/python/tensorflow.py', wdir='E:/python')
File "C:\Users\Harsh\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\Harsh\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "E:/python/tensorflow.py", line 9, in <module>
import tensorflow as tf
File "E:\python\tensorflow.py", line 18, in <module>
text = pytesseract.image_to_string(img)
File "C:\Users\Harsh\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 358, in image_to_string
}[output_type]()
File "C:\Users\Harsh\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 357, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\Harsh\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 266, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\Harsh\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 237, in run_tesseract
raise e
File "C:\Users\Harsh\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 234, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "C:\Users\Harsh\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 143, in __init__
super(SubprocessPopen, self).__init__(*args, **kwargs)
File "C:\Users\Harsh\Anaconda3\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\Harsh\Anaconda3\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
PermissionError: [WinError 5] Access is denied
my code
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 19 15:17:41 2020
#author: Harsh
"""
import cv2
#import tesseract as te
import tensorflow as tf
import numpy as np
import pytesseract
pytesseract.pytesseract.tesseract_cmd= r"C:\\Users\\Harsh\\Anaconda3\\envs\\tesseract\\Library\\bin"
img = cv2.imread("sample1.jpg")
text = pytesseract.image_to_string(img)
#print(pytesseract.image_to_string(Image.open("sample1.jpg")))
cv2.imshow("Img",img)
print(text)
cv2.waitKey(0)
Your pytesseract.pytesseract.tesseract_cmd is wrong. Read pytesseract doc how to set it correctly.

Spyder latest version

Did any one face this issue while downloading the latest Anaconda3 and opened spyder?
An error ocurred while starting the kernel
The error is:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site‑packages\spyder\plugins\ipythonconsole\plugin.py", line 1173, in create_kernel_manager_and_kernel_client
kernel_manager.start_kernel(stderr=stderr_handle, **kwargs)
File "C:\Users\user\AppData\Roaming\Python\Python37\site‑packages\jupyter_client\manager.py", line 301, in start_kernel
kernel_cmd, kw = self.pre_start_kernel(**kw)
File "C:\Users\user\AppData\Roaming\Python\Python37\site‑packages\jupyter_client\manager.py", line 248, in pre_start_kernel
self.write_connection_file()
File "C:\Users\user\AppData\Roaming\Python\Python37\site‑packages\jupyter_client\connect.py", line 474, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\user\AppData\Roaming\Python\Python37\site‑packages\jupyter_client\connect.py", line 138, in write_connection_file
with secure_write(fname) as f:
File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\user\AppData\Roaming\Python\Python37\site‑packages\jupyter_core\paths.py", line 435, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\user\AppData\Roaming\Python\Python37\site‑packages\jupyter_core\paths.py", line 361, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: %1 is not a valid Win32 application.
Any help will be appreciated !!

conda 4.7.12: conda update -n base conda fails

I am working with conda version 4.7.12. Running the command conda update -n base conda failed. I am getting the same result when trying to update other environments as well, but the problem seemed to start when this command failed the first time. The output is:
$ conda update -n base conda
Collecting package metadata (current_repodata.json): failed
WARNING conda.exceptions:print_unexpected_error_report(1208): KeyError(u'pkgs_dirs',)
Traceback (most recent call last):
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/exceptions.py", line 1206, in print_unexpected_error_report
message_builder.append(get_main_info_str(error_report['conda_info']))
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/cli/main_info.py", line 236, in get_main_info_str
info_dict['_' + key] = ('\n' + 26 * ' ').join(info_dict[key])
KeyError: u'pkgs_dirs'
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/exceptions.py", line 1074, in __call__
return func(*args, **kwargs)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/cli/main.py", line 84, in _main
exit_code = do_call(args, p)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/cli/conda_argparse.py", line 82, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/cli/main_update.py", line 20, in execute
install(args, parser, 'update')
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/cli/install.py", line 265, in install
should_retry_solve=(_should_retry_unfrozen or repodata_fn != repodata_fns[-1]),
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/core/solve.py", line 117, in solve_for_transaction
should_retry_solve)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/core/solve.py", line 158, in solve_for_diff
force_remove, should_retry_solve)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/core/solve.py", line 262, in solve_final_state
ssc = self._collect_all_metadata(ssc)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/common/io.py", line 88, in decorated
return f(*args, **kwds)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/core/solve.py", line 415, in _collect_all_metadata
index, r = self._prepare(prepared_specs)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/core/solve.py", line 1004, in _prepare
self.subdirs, prepared_specs, self._repodata_fn)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/core/index.py", line 250, in get_reduced_index
_supplement_index_with_system(reduced_index)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/core/index.py", line 155, in _supplement_index_with_system
cuda_version = context.cuda_version
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/_vendor/auxlib/decorators.py", line 268, in new_fget
cache[inner_attname] = func(self)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/common/decorators.py", line 20, in wrapper
return func(*args, **kwargs)
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/base/context.py", line 770, in cuda_version
return cuda_detect()
File "/home/XXXXXX/miniconda/lib/python2.7/site-packages/conda/common/cuda.py", line 19, in cuda_detect
system = platform.system()
AttributeError: 'module' object has no attribute 'system'
`$ /home/XXXXXX/miniconda/bin/conda update -n base conda`
environment variables:
conda info could not be constructed.
KeyError(u'pkgs_dirs',)
An unexpected error has occurred. Conda has prepared the above report.

OS X pip3 broken with brew install python3.6.5_1

I just did a fresh install of python3 (3.6.5_1) on Mac OS (High Sierra) and pip3 does not work. I get the following error with pip3:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in <module>
load_entry_point('pip==10.0.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
return self.resolve()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python3.6/site-packages/pip/_internal/index.py", line 39, in <module>
from pip._internal.wheel import Wheel, wheel_ext
File "/usr/local/lib/python3.6/site-packages/pip/_internal/wheel.py", line 7, in <module>
import compileall
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/compileall.py", line 20, in <module>
from concurrent.futures import ProcessPoolExecutor
File "/Library/Python/2.7/site-packages/concurrent/futures/__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/Library/Python/2.7/site-packages/concurrent/futures/_base.py", line 357
raise type(self._exception), self._exception, self._traceback
^
SyntaxError: invalid syntax
which pip3 returns /usr/local/bin/pip3
I have searched and can't find a solution.

Cannot install pylint on Windows 7 x64, Python 2.7, pip error

I'm trying to install pylint with pip install pylint
But i've got this at the end of installation:
Removing temporary dir c:\users\fixxxer\appdata\local\temp\pip_build_Fixxxer...
Exception:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python27\lib\site-packages\pip\commands\install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\Python27\lib\site-packages\pip\req.py", line 1229, in prepare_files
req_to_install.run_egg_info()
File "C:\Python27\lib\site-packages\pip\req.py", line 292, in run_egg_info
logger.notify('Running setup.py (path:%s) egg_info for package %s' % (self.setup_py, self.name))
File "C:\Python27\lib\site-packages\pip\req.py", line 265, in setup_py
import setuptools
File "C:\Python27\lib\site-packages\setuptools\__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "C:\Python27\lib\site-packages\setuptools\extension.py", line 7, in <module>
from setuptools.dist import _get_unpatched
File "C:\Python27\lib\site-packages\setuptools\dist.py", line 16, in <module>
from setuptools.depends import Require
File "C:\Python27\lib\site-packages\setuptools\depends.py", line 6, in <module>
from setuptools import compat
File "C:\Python27\lib\site-packages\setuptools\compat.py", line 19, in <module>
from SimpleHTTPServer import SimpleHTTPRequestHandler
File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "C:\Python27\lib\SimpleHTTPServer.py", line 204, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File "C:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)
Any ideas how can i fix this or some workarounds?
How can i install it manually?
UPDATE.
replacing
default_encoding = sys.getdefaultencoding()
with
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
default_encoding = sys.getdefaultencoding()
does this:
Cleaning up...
Removing temporary dir c:\users\fixxxer\appdata\local\temp\pip_build_Fixxxer...
Exception:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python27\lib\site-packages\pip\commands\install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\Python27\lib\site-packages\pip\req.py", line 1229, in prepare_files
req_to_install.run_egg_info()
File "C:\Python27\lib\site-packages\pip\req.py", line 292, in run_egg_info
logger.notify('Running setup.py (path:%s) egg_info for package %s' % (self.setup_py, self.name))
File "C:\Python27\lib\site-packages\pip\req.py", line 265, in setup_py
import setuptools
File "C:\Python27\lib\site-packages\setuptools\__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "C:\Python27\lib\site-packages\setuptools\extension.py", line 7, in <module>
from setuptools.dist import _get_unpatched
File "C:\Python27\lib\site-packages\setuptools\dist.py", line 16, in <module>
from setuptools.depends import Require
File "C:\Python27\lib\site-packages\setuptools\depends.py", line 6, in <module>
from setuptools import compat
File "C:\Python27\lib\site-packages\setuptools\compat.py", line 19, in <module>
from SimpleHTTPServer import SimpleHTTPRequestHandler
File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "C:\Python27\lib\SimpleHTTPServer.py", line 204, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File "C:\Python27\lib\mimetypes.py", line 359, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 263, in read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'gbk' codec can't decode bytes in position 4-5: illegal multibyte sequence
Found a problem.
There was a few MIME types with Cyrillic names in
HKEY_CLASSES_ROOT\MIME\Database\Content Type
Removed them and problem was solved.
I had the same error and this helped me https://stackoverflow.com/a/23278373/2571607
Basically, open C:\Python27\Lib\mimetypes.py
replace
‘default_encoding = sys.getdefaultencoding()’
with
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
default_encoding = sys.getdefaultencoding()

Resources