I have a problem when I install the package control of sublime text 3 because of the proxy set but I need to install a plugin. When I do getproxy
in the console it returns me {} and when I try to set the proxy with python in console with
urllib.set_proxy('http://user:password@server:port', 'http')
I replaced the user, password, server and port by their values but it returns me
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'set_proxy'
what can I do to make it work? I need to install a plugin .
You will need to setup your proxy server in the Package Control
settings.
Copy and paste the code below into a file called Package Control.sublime-settings
which must be saved in your User
config folder. That is the same folder as your USER Preferences.sublime-settings
file is saved in. The Data Directory states where this is on your operating system. i.e.
%APPDATA%\Sublime Text 3\Packages\User\Package Control.sublime-settings
~/Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings
~/.config/sublime-text-3/Packages/User/Package Control.sublime-settings
Clearly you must add the domain and port and your user name and password in the relevant fields below. The proxy should be in the form: proxyserver:port
. e.g.
{
"http_proxy": "server.com:80",
"https_proxy": "server.com:8080",
"proxy_username": "mynameis",
"proxy_password": "mypassis",
}
See also: Package Control Settings
{
// An HTTP proxy server to use for requests. Not normally used on Windows
// since the system proxy configuration is utilized via WinINet. However,
// if WinINet is not working properly, this will be used by the Urllib
// downloader, which acts as a fallback.
"http_proxy": "",
// An HTTPS proxy server to use for requests - this will inherit from
// http_proxy if it is set to "" or null and http_proxy has a value. You
// can set this to false to prevent inheriting from http_proxy. Not
// normally used on Windows since the system proxy configuration is
// utilized via WinINet. However, if WinINet is not working properly, this
// will be used by the Urllib downloader, which acts as a fallback.
"https_proxy": "",
// Username and password for both http_proxy and https_proxy. May be used
// with WinINet to set credentials for system-level proxy config.
"proxy_username": "",
"proxy_password": "",
}
You could simply run the below command in the Sublime 3 console (launch console using CTRL+`
or View -> Show Console
)
import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler({'http': 'http://USER:PASSWORD@HOST:PORT', 'https': 'https://USER:PASSWORD@HOST:PORT'})) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())
In the above code, you need to replace the value(USER:PASSWORD@HOST:PORT
) of http
and https
keys as per your proxy details
Then hit Enter
and it will install the Package Control
using the provided proxy
I exactly had the same issue, I was unable to download packages for Sublime Text 3. I set up the proxy server at runtime as shown in below snippet in the Sublime console (Mac Shortcut Ctrl + `) and it worked for me.
import os
proxy_server = 'http://username:password@proxy_server_name:port'
os.environ['http_proxy'] = proxy_server
os.environ['HTTP_PROXY'] = proxy_server
os.environ['https_proxy'] = proxy_server
os.environ['HTTPS_PROXY'] = proxy_server
os.environ['all_proxy'] = proxy_server
os.environ['ALL_PROXY'] = proxy_server
os.environ['ftp_proxy'] = proxy_server
os.environ['FTP_PROXY'] = proxy_server
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With