urllib.error.URLError: <urlopen error [Errno 0] Error> - https

I use python3.7.2 urllib request a https url raise a error. how to fix it. thank you.
if replace https with http return ok. but this contation https is reqyuired.
import ssl
import urllib.request
if __name__ == '__main__':
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
response = urllib.request.urlopen('https://igionline.com/viewpdf.htm?itemno=LG11151502', timeout=10, context=ssl_context)
Traceback (most recent call last):
File "/home/wmh/Python-3.7.2/Lib/urllib/request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/home/wmh/Python-3.7.2/Lib/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/home/wmh/Python-3.7.2/Lib/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/home/wmh/Python-3.7.2/Lib/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/home/wmh/Python-3.7.2/Lib/http/client.py", line 1016, in _send_output
self.send(msg)
File "/home/wmh/Python-3.7.2/Lib/http/client.py", line 956, in send
self.connect()
File "/home/wmh/Python-3.7.2/Lib/http/client.py", line 1392, in connect
server_hostname=server_hostname)
File "/home/wmh/Python-3.7.2/Lib/ssl.py", line 412, in wrap_socket
session=session
File "/home/wmh/Python-3.7.2/Lib/ssl.py", line 853, in _create
self.do_handshake()
File "/home/wmh/Python-3.7.2/Lib/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
OSError: [Errno 0] Error

Related

Jupyter - failed to start the kernel

i am suddenly getting the following error when trying to launch a jupyter-notebook: "Failed to start the kernel"- Unhandled error. Any ideas how to fix this?
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyter_client\manager.py", line 259, in start_kernel
**kw)
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyter_client\manager.py", line 204, in _launch_kernel
return launch_kernel(kernel_cmd, **kw)
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyter_client\launcher.py", line 138, in launch_kernel
proc = Popen(cmd, **kwargs)
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\USER\AppData\Local\Continuum\anaconda3\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden
typing the following command in the anaconda prompt solved the issue:
python -m ipykernel install --user

Apache Arrow connectivity issue with HDFS (Remote file-system)

I want to connect pyarrow to read to and write parquet file in hdfs
But I am facing some connectivity issue
I installed pyarrow and python pandas now I am trying to connect with hdfs
in remote machine
Reference link - https://towardsdatascience.com/a-gentle-introduction-to-apache-arrow-with-apache-spark-and-pandas-bb19ffe0ddae
import pyarrow as pa
host = '172.17.0.2'
port = 8020
fs = pa.hdfs.connect(host, port)
Error messages
>>> fs = pa.hdfs.connect(host, port)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/pyarrow/hdfs.py", line 211, in connect
extra_conf=extra_conf)
File "/usr/lib64/python2.7/site-packages/pyarrow/hdfs.py", line 36, in __init__
_maybe_set_hadoop_classpath()
File "/usr/lib64/python2.7/site-packages/pyarrow/hdfs.py", line 136, in _maybe_set_hadoop_classpath
classpath = _hadoop_classpath_glob('hadoop')
File "/usr/lib64/python2.7/site-packages/pyarrow/hdfs.py", line 161, in _hadoop_classpath_glob
return subprocess.check_output(hadoop_classpath_args)
File "/usr/lib64/python2.7/subprocess.py", line 568, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Problems loading mnist in tensorflow on Mac OS

Please help, I encountered the following errors while attempting to download the MNIST dataset with Tensorflow.
Using TensorFlow backend.
Downloading data from https://s3.amazonaws.com/img-datasets/mnist.npz
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 401, in wrap_socket
_context=self, _session=session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 808, in __init__
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1061, in do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/utils/data_utils.py", line 207, in get_file
urlretrieve(origin, fpath, dl_progress)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 248, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/lorin/Applications/miniconda3/envs/udemy/mnist_keras.py", line 13, in <module>
(X_train, y_train), (X_test, y_test) = mnist.load_data('/lib/python3.6/site-packages/keras/datasetsmnist.py')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/datasets/mnist.py", line 15, in load_data
path = get_file(path, origin='https://s3.amazonaws.com/img-datasets/mnist.npz')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/utils/data_utils.py", line 209, in get_file
raise Exception(error_msg.format(origin, e.errno, e.reason))
Exception: URL fetch failure on https://s3.amazonaws.com/img-datasets/mnist.npz: None -- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)
Process finished with exit code enter code here
I had the same issue, and the command below (as indicated in https://github.com/tensorflow/tensorflow/issues/10779) helped:
/Applications/Python\ 3.6/Install\ Certificates.command
I suggest you install TensorFlow in a separate virtualenv.
Follow the following steps here: Installing TensorFlow with virtualenv
And always remember to activate the virtualenv environment each time you use TensorFlow in a new shell by running:
$ source ~/<target_directory>/bin/activate
I installed the latest version of Pip and the issue was fixed
Update using the following command:
"pip install --upgrade pip"
TensorFlow 2 packages require a pip version >19.0.

urllib.error.URLError: <urlopen error [Errno 11004] getaddrinfo failed>

I am trying to configure sublime text 3 with AngularJS. I copied the message i found on the internet for sublime text 3 to the console to install the package controller:
import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
I got this error:
Traceback (most recent call last):
File "./python3.3/urllib/request.py", line 1248, in do_open
File "./python3.3/http/client.py", line 1065, in request
File "./python3.3/http/client.py", line 1103, in _send_request
File "./python3.3/http/client.py", line 1061, in endheaders
File "./python3.3/http/client.py", line 906, in _send_output
File "./python3.3/http/client.py", line 844, in send
File "./python3.3/http/client.py", line 822, in connect
File "./python3.3/socket.py", line 417, in create_connection
socket.gaierror: [Errno 11004] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "./python3.3/urllib/request.py", line 156, in urlopen
File "./python3.3/urllib/request.py", line 469, in open
File "./python3.3/urllib/request.py", line 487, in _open
File "./python3.3/urllib/request.py", line 447, in _call_chain
File "./python3.3/urllib/request.py", line 1274, in http_open
File "./python3.3/urllib/request.py", line 1251, in do_open
urllib.error.URLError: <urlopen error [Errno 11004] getaddrinfo failed>
I have found different solution on the Internet, but nothing worked for me. I would appreciate if u could help me. Thank you!

GitPython log() Error

I have a problem with the method log()
repo = git.Repo(repo_path)
branch = repo.head
log = branch.log()
print log
Error:
Traceback (most recent call last): File "gitpython.py",
line 29, in <module log = branch.log() File
"/usr/local/lib/python2.7/dist-packages/GitPython-2.0.9dev0-py2.7.egg/git/refs/symbolic.py", line 361, in log
return RefLog.from_file(RefLog.path(self)) File "/usr/local/lib/python2.7/dist-packages/GitPython-2.0.9dev0-py2.7.egg/git/refs/log.py",
line 179, in from_file
return cls(filepath) File "/usr/local/lib/python2.7/dist-packages/GitPython-2.0.9dev0-py2.7.egg/git/refs/log.py",
line 153, in __init__
self._read_from_file() File "/usr/local/lib/python2.7/dist-packages/GitPython-2.0.9dev0-py2.7.egg/git/refs/log.py",
line 165, in _read_from_file
self._deserialize(fmap) File "/usr/local/lib/python2.7/dist-packages/GitPython-2.0.9dev0-py2.7.egg/git/refs/log.py",
line 318, in _deserialize
self.extend(self.iter_entries(stream)) File "/usr/local/lib/python2.7/dist-packages/GitPython-2.0.9dev0-py2.7.egg/git/refs/log.py",
line 205, in iter_entries
yield new_entry(line.strip()) File "/usr/local/lib/python2.7/dist-packages/GitPython-2.0.9dev0-py2.7.egg/git/refs/log.py",
line 123, in from_line
raise ValueError("Missing token: >") ValueError: Missing token: >
Did you update gitpython?
File "/usr/local/lib/python2.7/dist-packages/GitPython-2.0.9dev0-py2.7.egg/git/refs/log.py",
line 123, in from_line
raise ValueError("Missing token: >") ValueError: Missing token: >
Seems to indicate something wrong in the log.py file.

Resources