cling on Jupyter on Windows: Kernel cannot start - c++

Background: I am trying to install the cling c++ interpreter here. I am on a Windows and have had Anaconda running well, Jupyter notebook also working fine with the existing Python kernels. The installation process was smooth on the surface but there is Kernel error once I try to open Jupyter notebook on the installed Kernel.
(In the end I would hope to be able to use c++ with Jupyter notebook so if anyone has had any success please could you share your experience. On that, while the xeus-cling is not usable for Windows as many say, this cling appears to be a separate thing)
The installation: Here is what I have done:
Download the binary cling_2019-11-28_arm64.tar.bz2 (is this correct for Windows?) from
https://root.cern.ch/download/cling/
Extract and place in Program Files folder
Following the instruction in here, add C:\Program Files\cling_2019-11-28_arm64\bin to the PATH variable
Activate base Anaconda environment
cd .../share/cling/Jupyter/kernel
pip install -e .
jupyter-kernelspec install --user cling-cpp11
Every thing seems to be fine up to here, no warning/error.
The error: Then I load up my Jupyter notebook and try to run the cpp11 kernel, but it is unable to start with a long error traceback, the first/last items of which read:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 736, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 73, in post
type=mtype))
... (omitted) ...
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\launcher.py", line 138, in launch_kernel
proc = Popen(cmd, **kwargs)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
And on the cmd the following:
[E 14:39:14.265 NotebookApp] Failed to run command:
['jupyter-cling-kernel', '-f', 'path\\to\\jupyter\\runtime\\kernel-..(random string here)..json', '--std=c++11']
The troubleshooting (1): ... appearing to suggest that it is unable to locate a jupyter-cling-kernel. But I do have file named jupyter-cling-kernel in the .../Anaconda3/Scripts folder, and this folder is also in my PATH variable. After opening it, I discovered it is a python file with only a few lines. Looks like it corresponds to the command above.
#!C:\ProgramData\Anaconda3\python.exe
# EASY-INSTALL-DEV-SCRIPT: 'clingkernel==0.0.2','jupyter-cling-kernel'
__requires__ = 'clingkernel==0.0.2'
__import__('pkg_resources').require('clingkernel==0.0.2')
__file__ = 'C:\\Program Files\\cling_2019-11-28_arm64\\share\\cling\\Jupyter\\kernel\\scripts\\jupyter-cling-kernel'
with open(__file__) as f:
exec(compile(f.read(), __file__, 'exec'))
so then I modified my kernel.json file, adding the absolute python path (so that it knows to run it with python) and the absolute path of the jupyter-cling-kernel. (originally it was just "argv:["jupyter-cling-kernel", "-f", ...)
{
"display_name": "C++11",
"argv": [
**"C:\\ProgramData\\Anaconda3\\python.exe",
"C:\\ProgramData\\Anaconda3\\Scripts\\jupyter-cling-kernel",**
"-f",
"{connection_file}",
"--std=c++11"
],
"language": "C++"
}
The troubleshooting (2):... which indeed appears to be the right direction, at least it is running sth but now another error:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\jupyter-cling-kernel", line 7, in <modu
le>
exec(compile(f.read(), __file__, 'exec'))
File "C:\Program Files\cling_2019-11-28_arm64\share\cling\Jupyter\kernel\scrip
ts\jupyter-cling-kernel", line 3, in <module>
from clingkernel import main
File "c:\program files\cling_2019-11-28_arm64\share\cling\jupyter\kernel\cling
kernel.py", line 24, in <module>
from fcntl import fcntl, F_GETFL, F_SETFL
ModuleNotFoundError: No module named 'fcntl'
Now with some googling this fcntl appears to be sth not for Windows. So at this point I am wondering have I downloaded the wrong binary or should I modify this clingkernel.py file or do I need to do some compilation myself?
Again, if any of you knows of how to get the c++ run of Jupyter (on windows), appreciate if you could share your experience. Thanks.

With Windows 10 + WSL, we can install xeus-cling for C++ on Windows
Steps includes
Enable Ubuntu on WSL
Install Miniconda
Setup Conda, Jupyter Notebook, Xeus-Cling
This cling notebook with the cpp environment can be made to run from a desktop shortcut. Steps are documented on C/C++ Jupyter Notebook using xeus-cling - Windows WSL Setup

The cling interpreter has been packaged for conda-forge.
You can simply run
conda install cling -c conda-forge
and then run cling. However, unfortunately, the Jupyter kernel is not included with that build, and the windows build has some issues with IO operations which I am currently investigating.

Maybe try restarting the kernel by pressing o(not 0) twice.

Related

fbprophet failed to build wheel in google cloud function

I am hoping to use Fbprophet on my cloud function in a Python 3.7 environment, but it fails to build and gives me the following error.
Build failed: `pip_download_wheels` had stderr output:
ERROR: Command errored out with exit status 1:
command: /opt/python3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-srnqu7b5/fbprophet/setup.py'"'"'; __file__='"'"'/tmp/pip-wheel-srnqu7b5/fbprophet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-3_5khs54
cwd: /tmp/pip-wheel-srnqu7b5/fbprophet/
Complete output (40 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/fbprophet
creating build/lib/fbprophet/stan_model
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-wheel-srnqu7b5/fbprophet/setup.py", line 148, in <module>
"""
File "/opt/python3.7/lib/python3.7/site-packages/setuptools/__init__.py", line 140, in setup
return distutils.core.setup(**attrs)
File "/opt/python3.7/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/python3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/opt/python3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/opt/python3.7/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 202, in run
self.run_command('build')
File "/opt/python3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/python3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/opt/python3.7/lib/python3.7/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/opt/python3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/python3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-wheel-srnqu7b5/fbprophet/setup.py", line 48, in run
build_models(target_dir)
File "/tmp/pip-wheel-srnqu7b5/fbprophet/setup.py", line 36, in build_models
from fbprophet.models import StanBackendEnum
File "/tmp/pip-wheel-srnqu7b5/fbprophet/fbprophet/__init__.py", line 8, in <module>
from fbprophet.forecaster import Prophet
File "/tmp/pip-wheel-srnqu7b5/fbprophet/fbprophet/forecaster.py", line 14, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
----------------------------------------
ERROR: Failed building wheel for fbprophet
ERROR: Failed to build one or more wheels
error: `pip_download_wheels` returned code: 1; Error ID: 618AA8E7
This is what my requirements.txt file looks like:
cython
pystan
numpy
pandas==1.0.3
google-cloud-storage==1.29.0
fbprophet
geopy==1.22.0
google-cloud-bigquery==1.25.0
Everything works perfectly fine locally in a Python 3.7 virtual environment on jupyter notebook. Would appreciate any help because I've spent almost an entire day trying to fix this but to no avail.
I'm having similar issues to this. My goal is to deploy a function that, when passed some input, will feed this into a Prophet model in order to make a prediction before passing the prediction to another part of my system.
As far as I can tell, there are a few things that make this complicated.
First, there is the issue of build dependencies that #mgoya mentioned in the comment above. This manifests both when installing Prophet and when installing Pystan (a dependency of Prophet). In my cloudbuild.yaml I'm attempting to circumvent this by installing the dependencies in sequence, like this:
steps:
- name: 'docker.io/library/python:3.9'
entrypoint: /bin/sh
# Run pip install and pytest in the same build step
# (pip packages won't be preserved in future steps!)
args: [-c, 'pip uninstall pystan; pip install convertdate==2.1.2 lunarcalendar==0.0.9 holidays==0.10.3 pgen tqdm cython pandas numpy setuptools; pip install pystan==2.19.1.1; pip install -r requirements.txt']
timeout: 1200s
This first uninstalls Pystan (if one exists locally), then installs the build dependencies for Pystan (a build dependency for Prophet), then installs Prophet (which is included in my requirements.txt).
Note the semicolons. I ran into issues when using double-ampersands instead (i.e. pip install ... && pip install ... etc.. I believe this may be due to the way that the installed packages make their way to the local file system and are made available to the following commands. By running them with && this seems to try and run them all at once, which won't give the earlier parts of the installation time to propagate and be discoverable by later steps. Using semicolons seems to help with this but it's anecdotal evidence at best.
You could also try using python -m pip install ... rather than pip install though I'm not familiar enough with Python to tell you the difference off the top of my head.
Secondly, there are the memory requirements for installing Pystan. I've read somewhere that Pystan requires 4GB of memory to install. The default machine_type for cloudbuild does not have that much. You can try increasing the size of the machine by changing its type.
Finally, there's the resources allocated for function execution. Again, I read somewhere that Prophet / Pystan require 2GB of memory just to run one of the models. So, if your cloud function doesn't have this, it may run into memory issues when trying to execute. In my experience so far, memory issues are not that transparent within Google Cloud.
--
My current thinking (and perhaps what I'd recommend to anyone else reading this post) is to consider whether Cloud Functions is the right tool for this, given the weight of the dependencies. Pystan and Prophet are rather special-case dependencies, given their build and runtime resource requirements.
What I've opted to do is build (locally) a container with these dependencies baked in and pushing this to Google's Container Registry. My plan from here is to use that container as the base image for a Cloud Run application, which is significantly easier to deploy. This has obvious drawbacks but if my base image changes infrequently (which it will) I think this approach would be fine. Unfortunately, this model ("bring your own container") is not supported by Cloud Functions - it's designed where all you bring is code.

ERROR: command "pkg-config --modversion libgphoto2" failed

I am getting an error when I try to install Gphoto2 on my windows pc.
I have tried installing following the instructions from https://pypi.org/project/gphoto2/ and downloading the zip from git clone https://github.com/jim-easterbrook/python-gphoto2.git but have had no success.
This module is supposed to install successfully.
Using the PYPI https://pypi.org/project/gphoto2/
I have tried to follow and install this module also downloading and installing the zip from:
git clone https://github.com/jim-easterbrook/python-gphoto2.git
I have had great difficulty, any advice or suggestion would be greatly appreciated.
C:\Users\Sam\Downloads\python-gphoto2-master\python-gphoto2-master> python setup.py install
ERROR: command "pkg-config --modversion libgphoto2" failed
This module Gphoto2 is supposed to install successfully.
This is what the complete error says:
C:\Users\Sam\Downloads\python-gphoto2-master\python-gphoto2-master>
python setup.py install ERROR: command "pkg-config --modversion
libgphoto2" failed Traceback (most recent call last): File "setup.py",
line 36, in <module> cmd, stderr=FNULL,
universal_newlines=True).split('.') File
"C:\python27\lib\subprocess.py", line 212, in check_output process =
Popen(stdout=PIPE, *popenargs, **kwargs) Windows: [Error 2] The system cannot find the file specified
I'm the author of python-gphoto2.
Python-gphoto2 is not expected to work on Windows. The PyPI page (https://pypi.org/project/gphoto2/) shows the supported operating systems - MacOS and POSIX compatible (e.g. Linux).
I have been able to install it in MSYS2 (http://www.msys2.org/) but it isn't useful unless you get Windows to use libusb instead of its normal driver for your camera.

Pyinstaller-generated exe cannot run on another computer

My computer's OS is 64-bit win 10. Python 2.7, 32-bit.
My code is plot.py, simple as below:
import matplotlib.pyplot as plt
import FileDialog
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
When I execute pyinstaller -F plot.py, the generated
plot.exe works as expected on my current computer. However, I get an error if I try to run it on a different 32-bit Windows 7 computer:
Traceback (most recent call last):
File "site-packages\GUI_tempCtrl\plot.py", line 3, in <module>
File "lib\site-packages\matplotlib\pyplot.py", line 3147, in plot
File "lib\site-packages\matplotlib\pyplot.py", line 928, in gca
File "lib\site-packages\matplotlib\pyplot.py", line 578, in gcf
File "lib\site-packages\matplotlib\pyplot.py", line 527, in figure
File "lib\site-packages\matplotlib\backends\backend_tkagg.py", line 84, in new
_figure_manager
File "lib\site-packages\matplotlib\backends\backend_tkagg.py", line 92, in new
_figure_manager_given_figure
File "lib\lib-tk\Tkinter.py", line 1814, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
C:/Users/ADMINI~1/AppData/Local/Temp/lib/tcl8.5 C:/Users/Administrator/lib/t
cl8.5 C:/Users/lib/tcl8.5 C:/Users/Administrator/library C:/Users/library C:/Use
rs/tcl8.5.15/library C:/tcl8.5.15/library
This probably means that Tcl wasn't installed properly.
Failed to execute script plot
You can try downgrading pyinstaller to v3.1 and rebuilding your exe file on your first computer to solve this issue.
Alternatively, you can fix it on your second computer by setting the TCL_LIBRARY environment variable to C:\Python27\tcl\tcl8.5\ (or wherever tcl8.5 is located)
PyInstaller has a known issue with Tkinter applications on Windows 7 and Windows XP.
Since this issue has gone unfixed for two years, I've gone ahead and started a bounty. Until the issue is fixed, there are a few workarounds you can try:
Workaround 1 - Manually copy missing files
As mentioned in a related issue, you can manually copy the missing files from your local Python installation.
Find your local Python installation. (%LocalAppData%\Programs\Python)
Make a copy of the missing folder (...\Python36-32\tcl\<missing_folder>)
Move the copy to your application's tcl folder (...\dist\<app_name>\tcl\<missing_folder>)
Workaround 2 - Run with --onefile
Running PyInstaller in --onefile mode seems to avoid this issue.
However, note that running in single file mode will increase startup time.
Workaround 3 - Downgrade to PyInstaller 3.1.0
pip install pyinstaller==3.1.0
According to ugoertz, downgrading to PyInstaller 3.1.0 resolved the issue.
Downgrading to 3.1.0 (and also downgrading setuptools to 19.2 because of the problem described in #1941) fixed the issue for me.

uwsgi installation error in windows 7

Trying to install uwsgi according to documentation. I'm getting the below error on Windows 7.
What should I do?
(uwsgi-tutorial) C:\Users\Home\Videos\uwsgi-tutorial\mysite>pip install uwsgi
Collecting uwsgi
Using cached uwsgi-2.0.11.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "c:\users\home\appdata\local\temp\pip-build-04g1m6\uwsgi\setup.py", line 3, in <module>
import uwsgiconfig as uc
File "uwsgiconfig.py", line 8, in <module>
uwsgi_os = os.uname()[0]
AttributeError: 'module' object has no attribute 'uname'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\home\appdata\local\temp\pip-build-04g1m6\uwsgi
uWSGI can be compiled on Windows only using cygwin. There is no such thing as uname in normal Windows console, but it exists inside cygwin. If you're already in cygwin console, try to run uname command, if that exists, check if os.uname() in python inside cygwin is also working.
Latest news from the front, uWSGI perfectly works on Windows 10 in bash on Ubuntu on Windows
As Linux subsystem still in beta, i'd not recommend for production usage, however this will cover all dev needs.
P.S. i know that op ask about Windows 7, however as Windows 10 and Linux subsystem come to Windows world later, i think i can leave this here.
uWSGI can be compiled on Windows using Cygwin. But unfortunately, I was getting the same message with the Cygwin.
Here I am sharing the other way to install uWSGI on windows.
Step 1: Download the stable release and extract the tar file
Step 2: Open uwsgiconfig.py and import platform then replace os.uname()[index] with platform.uname()[index]
Change
uwsgi_os = os.uname()[0]
uwsgi_os_k = re.split('[-+_]', os.uname()[2])[0]
uwsgi_os_v = os.uname()[3]
uwsgi_cpu = os.uname()[4]
To
import platform
uwsgi_os = platform.uname()[0]
uwsgi_os_k = re.split('[-+_]', platform.uname()[2])[0]
uwsgi_os_v = platform.uname()[3]
uwsgi_cpu = platform.uname()[4]
Step 3: Run python setup.py install
Note: You may need to install GCC and configure it.

Getting error: DLL load failed: The operating system cannot run %1 - Python 2.7; Scrapy Module; Importing Cryptography

I cannot successfully run the first command in the Scrapy tutorial (http://doc.scrapy.org/en/latest/intro/tutorial.html). The code copy pasted below is the result (with the error at the end).
Python 2.7 is installed, and I followed the installation instructions for scrapy (http://doc.scrapy.org/en/latest/intro/install.html). I am running Python 2.7.6 32 bit on Windows 7 (64 bit).
Other aspects of installation:
Twisted-13.2.0.dist-info
zope.interface-4.1.1-py2.7
Scrapy-0.22.2-py2.7
lxml-3.3.3-py2.7
cssselect-0.9.1-py2.7
cryptography-0.3.dist-info
pyOpenSSL-0.14-py2.7
pywin32_system32
And here's the error message:
C:\Python27\Scripts>scrapy startproject tutorial
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\lib\site-packages\scrapy\cmdline.py", line 9, in <module>
from scrapy.crawler import CrawlerProcess
File "C:\Python27\lib\site-packages\scrapy\crawler.py", line 3, in <module>
from twisted.internet import reactor, defer
File "twisted\internet\reactor.py", line 38, in <module>
from twisted.internet import default
File "twisted\internet\default.py", line 56, in <module>
install = _getInstallFunction(platform)
File "twisted\internet\default.py", line 50, in _getInstallFunction
from twisted.internet.selectreactor import install
File "twisted\internet\selectreactor.py", line 18, in <module>
from twisted.internet import posixbase
File "twisted\internet\posixbase.py", line 24, in <module>
from twisted.internet import error, udp, tcp
File "twisted\internet\tcp.py", line 29, in <module>
from twisted.internet._newtls import (
File "twisted\internet\_newtls.py", line 21, in <module>
from twisted.protocols.tls import TLSMemoryBIOFactory, TLSMemoryBIOProtocol
File "twisted\protocols\tls.py", line 40, in <module>
from OpenSSL.SSL import Error, ZeroReturnError, WantReadError
File "build\bdist.win32\egg\OpenSSL\__init__.py", line 8, in <module>
File "build\bdist.win32\egg\OpenSSL\rand.py", line 11, in <module>
File "build\bdist.win32\egg\OpenSSL\_util.py", line 4, in <module>
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", l3, in __init__
self._ensure_ffi_initialized()
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", l9, in _ensure_ffi_initialized libraries)
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\utils.py", line 77, ind_ffi
ext_package="cryptography",
File "C:\Python27\lib\site-packages\cffi\api.py", line 341, in verify
lib = self.verifier.load_library()
File "C:\Python27\lib\site-packages\cffi\verifier.py", line 75, in load_library
return self._load_library()
File "C:\Python27\lib\site-packages\cffi\verifier.py", line 151, in _load_library
return self._vengine.load_library()
File "C:\Python27\lib\site-packages\cffi\vengine_cpy.py", line 138, in load_library
raise ffiplatform.VerificationError(error)
cffi.ffiplatform.VerificationError: importing 'C:\\Python27\\lib\\site-packages\\cryptogr
\_Cryptography_cffi_48bbf0ebx93c91939.pyd': DLL load failed: The operating system cannot
1.**
I just reinstall cryptography to make it work.
pip uninstall cryptography
pip install cryptography
I had this problem due to another (older?) version of libeay32.dll and ssleay32.dll being on the PATH before those of my own OpenSSL 1.0.1g installation. I recommend you use Process Monitor from SysInternals to monitor python.exe to see where it is actually loading your OpenSSL DLLs from.
In my case, the offender was some Intel components at C:\Program Files (x86)\Intel\iCLS Client\ that came with my drivers. After moving my own OpenSSL bin directory earlier in the PATH environment variable, everything worked as expected.
this is due to _Cryptography_cffi_48bbf0ebx93c91939.pyd depends on openssl dll ssleay32.dll and libeay32.dll. after you compile openssl on windows, u can copy these 2 files to system32.
#crazyzh1984's method is a little complex, but his supplement that posted at the bottom of his answer is very useful. I download the "Win32 OpenSSL v1.0.1g Light" at http://slproweb.com/products/Win32OpenSSL.html and then I could install pyOpenSSL successfully.
#lambokini is right,but i'cant comment on the answer, so come this one.
First download openssl source from http://www.openssl.org/
Second start "Visual Studio Command Prompt", compile and install openssl follow install guide(INSTALL.W32 or INSTALL.W64).
Then add "[openssl install path]\bin" to the environment variable "path",
and you can delete ssleay32.dll and libeay32.dll under system32.
Notice: dll will be load from the first place it seached.
for exmple: Path=xxx;d:\PHP5;d:\openssl\bin;
if ssleay32.dll and libeay32.dll also appears under PHP5,
then python will load that one.
I'll write my own take on this due to my extreme frustration and hopes that this might help some other poor chap with his issues getting scrapy to work on windows..
Had a similar issues with faulty libeay32.dll and ssleay32.dll, or so it would seem, but confirmed it with Process Monitor.
It all went to hell after those dll's were found in System32:
So i wasnt suffering from wrong PATHs (but i did change their order so system32 comes before C:\Program Files (x86)\Intel\iCLS Client\.
Next i used this site the other guys here pointed to. Ive used Win32 OpenSSL v1.0.2j Light, since the newer one (1.1.0b) didnt generate these dlls for me for some reason.
Generate them in a different bin folder so you see they are new, and then copy them to system32. Voila, scrapy command line works.
Also, as of today, anaconda's scrapy 1.1.2 does not create a key file for running scrapy commands, ive opened and closed a question about this issue here.
As others have said above, there are two .dll files that are loaded instead of the openssl that is downloaded with Scrapy. Those two .dll files are not compatible.
I resolved this by placing the downloaded .dll files (i used Anaconda to install scrapy) as a higher priority in the Environment Variables as shown in the attached image.
In Environment Variables, within System Variables and the "Path" i placed the Anaconda3 location as shown above at the top and therefore makes it the priority when python comes to load openssl
As already mentioned in the other answers, the issue is caused by the two files ssleay32.dll and libeay32.dll.
The error occurred when importing OpenSSL in Python
>>> from OpenSSL import crypto, SSL
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python27\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
ImportError: DLL load failed: The operating system cannot run %1.
Here's how I solved the issue on Windows 10. If you have git for Windows (download here) you can just copy these two files from Git\mingw64\bin\ to some location in your path. What worked for me was to copy them to c:\Windows (or else to the folder from which you're starting Python).
To find the locations of the dll files type at a cmd prompt:
>where libeay32.dll
C:\Program Files (x86)\Intel\TXE Components\TCS\libeay32.dll
...
C:\Users\me\AppData\Local\Programs\Git\mingw64\bin\libeay32.dll
I ran across this error today on a Windows 7 system. The problem for me was similar to #user2314737, #voetsjoeba, and #Olegp. libeay32.dll and ssleay32.dll where in folders related to Intel that were in the Windows path environmental variable.
Unfortunately, my system is locked (work computer), so I could not move the files or alter the system's path variable. Instead, I manually removed the Intel related items from the path variable that Python accesses using:
import os
os.environ['path'] = ';'.join(
filter(lambda x: 'intel' not in x.lower(), os.environ['path'].split(';'))
)
import OpenSSL