Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python py2exe "IOError...unknown url type: https" issue

So my Web Scrapper works fine when ran with IDLE/Python, but when I compile it into a single .exe file (using py2exe), it raises an IOError.

When using urllib module:

IOError: [Errno url error] unknown url type: 'https'

When using requests module:

requests.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.

I did notice, when compiling with py2exe, it said at the end that several "modules appear to be missing", including a OpenSSL.SSL, and several references to urllib, which might be the problem?

Any ideas, solutions...?

like image 957
Chris Nguyen Avatar asked Apr 02 '26 15:04

Chris Nguyen


2 Answers

Can you check if you have openssl installed on your Windows machine? openssl is an open source cryptographic library which is used by most *nix systems. I believe that requests and urllib uses the same underlying library.

Once you fix this and then compile, I'm hoping the errors go away.

Note: I am not fully familiar with how you can do it and I do not own a Windows machine to test some of the articles I found via Google search.

like image 63
Adi Krishnan Avatar answered Apr 08 '26 19:04

Adi Krishnan


try this out set "skip_archive": True,"unbuffered": True

setup(
      version = "1.0",            
      name = "MyApplication",
      url = "http://www.example.com",
      author = "yourname",
      author_email = "[email protected]",
      license = "https://www.binpress.com/license/",
      copyright = 'Copyright (c) 2017 MyApplication',
      windows=[{'script': "yourfile.py","icon_resources": [(0, "youricon.ico")],'copyright': "Copyright (c) 2017 MyApplication"}] ,options={'py2exe':{"skip_archive": True,"unbuffered": True,'packages':['Tkinter','PIL','sip','pyavrophonetic','speech_recognition','simplejson','tkSimpleDialog','tkFileDialog','io','tkMessageBox','Tkconstants','random','pyaudio','os','wave','pocketsphinx','sphinxbase','pyttsx']}}
     )
#name your reqired modules

then carefully copy paste the files said missing manually to under dist directory and other files under their respective directory as you can find some files missing under modules. Then make an installer for your exe using Inno Setup. Hope this helps. EDIT You can find extra installed modules in location likeD:\Python\Lib\site-packages and most of python's own modules in D:\Python\Lib

like image 36
Subrata Sarkar Avatar answered Apr 08 '26 19:04

Subrata Sarkar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!