Sublime Forum

Python SSL Module

#1

When I try to import the ssl module for use in a package I am getting an import error about no module named _ssl. It appears there is an ssl.pyo in the Sublime Text 2/lib/python26.zip file, so I’m unsure if this is a bug or if the bundled version of Python was not compiled with SSL support.

0 Likes

#2

So this appears to only be an issue on Linux. I ended up working around it for now by creating wrappers for curl and wget and using those when I encounter https URLs and the ssl module won’t import.

0 Likes

#3

have the same bug.
I want to use sublime github and then i did commit i saw

Traceback (most recent call last): File "./gist.py", line 148, in on_done File "./gist.py", line 76, in create AttributeError: 'module' object has no attribute 'HTTPSConnection'

And when i import ssl i saw:

>>> import ssl Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib/sublime-text-2/lib/python26.zip/ssl.py", line 60, in <module> ImportError: No module named _ssl

Can i use python from my system unless python26.zip from “lib”?

0 Likes

#4

I spoke with Jon about this and he said that he had to remove it for Linux builds because of issues with different people who either didn’t have openssl or a different version, etc. I ended up writing three downloader classes, one for urllib2, one that wraps curl and one that wraps wget. Since Linux is the only affected platform and most Linux users have either Curl or Wget installed, it seems to have worked out pretty well. You can check out the Package Control source if you want to grab some code to start with: github.com/wbond/sublime_packag … ol.py#L340

0 Likes

#5

So, we need to wait Jon? Or i can fix that from myself? Can i use python from my system unless python26.zip from “lib”?

0 Likes

#6

I updated sublime-github to try to use curl if SSL support isn’t compiled into python. I borrowed some chunks of wbond’s code for it (thanks!).

github.com/bgreenlee/sublime-gi … 44850e2343

I didn’t bother with wget, since I believe curl is more common. If someone desperately needs wget support for some reason, I can add it.

0 Likes

#7

bgreenlee, thanks.
But not work for me.
In console:

Traceback (most recent call last): File "./gist.py", line 160, in on_done File "./gist.py", line 90, in create File "./curl.py", line 26, in post NameError: global name 'error_message' is not defined
If i comment error_message on curl.py, i see in console:

Traceback (most recent call last): File "./gist.py", line 160, in on_done File "./gist.py", line 91, in create File ".\re.py", line 137, in match TypeError: expected string or buffer

0 Likes

#8

@krim: Ok, I’ll set up a Linux VM to test this out on (works for me on OS X). What are you running?

0 Likes