我有一个问题,当我安装sublime文本3的包控件因为代理集但我需要安装插件所以有人可以帮助我吗?当我在控制台中执行getproxy时它返回我{}当我尝试在控制台中使用python设置代理
urllib.set_proxy('http://user:password@server:port','http')
我用他们的值替换了用户,密码,服务器和端口,但它返回了我
raceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'set_proxy'
我能做些什么让它有效?我需要安装一个插件
答案 0 :(得分:10)
您需要在Package Control
设置中设置代理服务器。
将以下代码复制并粘贴到名为Package Control.sublime-settings
的文件中,该文件必须保存在User
配置文件夹中。该文件夹与 USER Preferences.sublime-settings
文件保存在。The Data Directory状态的文件夹中的文件位于您的操作系统上。即。
%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
显然,您必须在下面的相关字段中添加域名和端口以及您的用户名和密码。代理应采用以下格式:proxyserver:port
。 e.g。
{
"http_proxy": "server.com:80",
"https_proxy": "server.com:8080",
"proxy_username": "mynameis",
"proxy_password": "mypassis",
}
{
// 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": "",
}
答案 1 :(得分:3)
您只需在Sublime 3控制台(使用CTRL+`
或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())
在上面的代码中,您需要根据代理详细信息替换USER:PASSWORD@HOST:PORT
和http
键的值(https
)
然后点击Enter
,它将使用提供的代理安装Package Control
答案 2 :(得分:0)
我确实遇到了同样的问题,我无法下载Sublime Text 3的软件包。我在运行时设置了代理服务器,如Sublime控制台中的以下片段所示(Mac快捷键Ctrl +`),它对我有用
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
答案 3 :(得分:0)
socks5
代理设置:菜单栏:Preferences > Package Settings > Package Control > Settings
注意:curl
下载程序后端支持socks5
。
{
"downloader_precedence": {
"linux": ["curl"]
},
"http_proxy": "socks5://127.0.0.1:1080",
"proxy_password": "",
"proxy_username": "",
...