Solved

Issues Installing pyOpenSSL for Python 2.7 in Windows

Posted on 2014-10-02
2
2,608 Views
Last Modified: 2014-10-23
Hey Guys -

I'm really frustrated.  I've got a small python-run app which I'm trying to enable SSL on.   After enabling SSL, I try to start the app via it's py file and it fails.  Logs show the following:

raise ImportError("You must install pyOpenSSL to use HTTPS.")
ImportError: You must install pyOpenSSL to use HTTPS.

Open in new window


So... I already have Python 2.7 installed (in C:\Python27) but now must install pyOpenSSL.  No matter what I try, I can't get it to install.  Below is what I've tried so far without luck...

#1 - Tried installing  pyOpenSSL via command line
I downloaded the entire pyOpenSSL package from Github, extracted to a folder in my Python folder, and ran the command "python setup.py install --user".  After a few seconds, I get the error "error: Setup script exited with error: Unable to find vcvarsall.bat"  

Note:  The entire log from the install attempt is at the end of this post

#2 - Trying to fix vcvarsall.bat error
I found many references to fixing it online so started trying things...

First, I read Setup Tools needed to be installed.  I installed it for Winx32 (since my Python's x32) but no change.  It was installed via an MSI named "setuptools-5.8.win32-py2.7.msi"

Next, I found a post saying it was due to Visual Studio 2010 issues.  I ended up installing Visual Studio 2010 Express (which I didn't want to do), adding an environment variable (which I tested to work), plus editing a couple of lines in msvc9compiler.py.  After all of this - same error :(

I finally found an MSI package at eGenix which a post said would allow me to install  pyOpenSSL witout having to compile it.  I got the Winx32 version for Python 2.7, installed it, then tried opening my Python app again.  No change!

I was going to go ahead and uninstall VBSE, but don't know if I'll still need it for a fix.  I've already wasted 2 hours on this.  My system specs are below:

System Specs
- Intel i7 / 16gb RAM
- Windows 8.1 Update 1 x64 (Fully Patched)
- Python 2.7 installed to C:\Python27
  (I used version 2.7 instead of 3 as I read for the app I use it for, 2.x had less issues)

Any help would be appreciated!

Complete Log from pyOpenSSL Install Attempt (After making changes to msvc9compiler.py listed in link above)
C:\Python27\pyopenssl>python setup.py install --user
running install
running bdist_egg
running egg_info
writing requirements to pyOpenSSL.egg-info\requires.txt
writing pyOpenSSL.egg-info\PKG-INFO
writing top-level names to pyOpenSSL.egg-info\top_level.txt
writing dependency_links to pyOpenSSL.egg-info\dependency_links.txt
reading manifest file 'pyOpenSSL.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'README'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
no previously-included directories found matching 'doc\_build'
writing manifest file 'pyOpenSSL.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
creating build\bdist.win32\egg
creating build\bdist.win32\egg\OpenSSL
copying build\lib\OpenSSL\crypto.py -> build\bdist.win32\egg\OpenSSL
copying build\lib\OpenSSL\rand.py -> build\bdist.win32\egg\OpenSSL
copying build\lib\OpenSSL\SSL.py -> build\bdist.win32\egg\OpenSSL
creating build\bdist.win32\egg\OpenSSL\test
copying build\lib\OpenSSL\test\test_crypto.py -> build\bdist.win32\egg\OpenSSL\test
copying build\lib\OpenSSL\test\test_rand.py -> build\bdist.win32\egg\OpenSSL\test
copying build\lib\OpenSSL\test\test_ssl.py -> build\bdist.win32\egg\OpenSSL\test

copying build\lib\OpenSSL\test\util.py -> build\bdist.win32\egg\OpenSSL\test
copying build\lib\OpenSSL\test\__init__.py -> build\bdist.win32\egg\OpenSSL\test

copying build\lib\OpenSSL\tsafe.py -> build\bdist.win32\egg\OpenSSL
copying build\lib\OpenSSL\version.py -> build\bdist.win32\egg\OpenSSL
copying build\lib\OpenSSL\_util.py -> build\bdist.win32\egg\OpenSSL
copying build\lib\OpenSSL\__init__.py -> build\bdist.win32\egg\OpenSSL
byte-compiling build\bdist.win32\egg\OpenSSL\crypto.py to crypto.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\rand.py to rand.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\SSL.py to SSL.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\test\test_crypto.py to test_crypto.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\test\test_rand.py to test_rand.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\test\test_ssl.py to test_ssl.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\test\util.py to util.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\test\__init__.py to __init__.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\tsafe.py to tsafe.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\version.py to version.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\_util.py to _util.pyc
byte-compiling build\bdist.win32\egg\OpenSSL\__init__.py to __init__.pyc
creating build\bdist.win32\egg\EGG-INFO
copying pyOpenSSL.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO
copying pyOpenSSL.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO
copying pyOpenSSL.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO
copying pyOpenSSL.egg-info\requires.txt -> build\bdist.win32\egg\EGG-INFO
copying pyOpenSSL.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist\pyOpenSSL-0.14-py2.7.egg' and adding 'build\bdist.win32\egg' to it
removing 'build\bdist.win32\egg' (and everything under it)
Processing pyOpenSSL-0.14-py2.7.egg
Removing c:\users\kelnet\appdata\roaming\python\python27\site-packages\pyOpenSSL-0.14-py2.7.egg
Copying pyOpenSSL-0.14-py2.7.egg to c:\users\kelnet\appdata\roaming\python\python27\site-packages
pyOpenSSL 0.14 is already the active version in easy-install.pth

Installed c:\users\kelnet\appdata\roaming\python\python27\site-packages\pyopenssl-0.14-py2.7.egg
Processing dependencies for pyOpenSSL==0.14
Searching for cryptography>=0.5.4
Reading https://pypi.python.org/simple/cryptography/Best match: cryptography 0.6
Downloading https://pypi.python.org/packages/source/c/cryptography/cryptography-0.6.tar.gz#md5=674a4524f4003d4f90e63c927c18c328
Processing cryptography-0.6.tar.gz
Writing c:\users\kelnet\appdata\local\temp\easy_install-vnfpqa\cryptography-0.6\setup.cfg
Running cryptography-0.6\setup.py -q bdist_egg --dist-dir c:\users\kelnet\appdata\local\temp\easy_install-vnfpqa\cryptography-0.6\egg-dist-tmp-m31wio
Searching for cffi>=0.8
Reading https://pypi.python.org/simple/cffi/
Best match: cffi 0.8.6
Downloading https://pypi.python.org/packages/source/c/cffi/cffi-0.8.6.tar.gz#md5=474b5a68299a6f05009171de1dc91be6
Processing cffi-0.8.6.tar.gz
Writing c:\users\kelnet\appdata\local\temp\easy_install-vnfpqa\cryptography-0.6\temp\easy_install-c6fwwn\cffi-0.8.6\setup.cfg
Running cffi-0.8.6\setup.py -q bdist_egg --dist-dir c:\users\kelnet\appdata\local\temp\easy_install-vnfpqa\cryptography-0.6\temp\easy_install-c6fwwn\cffi-0.8.6\egg-dist-tmp-7fi7og
error: Setup script exited with error: Unable to find vcvarsall.bat

Open in new window

0
Comment
Question by:BzowK
  • 2
2 Comments
 
LVL 25

Assisted Solution

by:clockwatcher
clockwatcher earned 500 total points
Comment Utility
I would highly suggest installing a pre-built version.  

There's a 32-bit pre-built binary MSI installer available for download from pypi:

    https://pypi.python.org/pypi/pyOpenSSL/0.13.  

There's a 64-bit pre-built MSI installer available for download from egenix at:

     http://www.egenix.com/products/python/pyOpenSSL/

Which you need depends upon the bitness of the python you installed.  If you're not sure, starting a python interpreter from the command line will tell you.

C:\Users\mark>python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenSSL.SSL
>>> quit()

Open in new window

0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
Comment Utility
Reread your post and noticed that you found the egenix installer.  I went ahead and tested the install on one of my 64-bit pythons and it installed fine for me:
C:\Users\mark>c:\python27\python
Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenSSL.SSL
>>> quit()

Open in new window


You can check your install with the above.

What app are you trying to run?  Is it something that you've written or something that you downloaded from somewhere?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A short article about problems I had with the new location API and permissions in Marshmallow
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now