作者:手浪用户2602928705 | 来源:互联网 | 2023-02-06 12:49
我有一个问题,当我安装sublime文本3的包控件因为代理集但我需要安装一个插件所以任何人都可以帮助我吗?当我在控制台中执行getproxy时它返回我{}当我尝试在控制台中使用python设置代理时
urllib.set_proxy(' http:// user:password @ server:port ','http')
我用他们的值替换了用户,密码,服务器和端口,但它返回了我
raceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute 'set_proxy'
我该怎么做才能使它有效?我需要安装一个插件
1> mattst..:
设置程序包控制从代理服务器后面工作
您需要在设置中设置代理服务器Package Control
.
将下面的代码复制并粘贴到一个Package Control.sublime-settings
必须保存在User
配置文件夹中的文件中.该文件夹与保存USER Preferences.sublime-settings
文件的文件夹相同.数据目录说明了操作系统中的位置.即
视窗: %APPDATA%\Sublime Text 3\Packages\User\Package Control.sublime-settings
OS X: ~/Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings
Linux的: ~/.config/sublime-text-3/Packages/User/Package Control.sublime-settings
显然,您必须在下面的相关字段中添加域和端口以及您的用户名和密码.代理应采用以下形式:proxyserver:port
.例如
{
"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": "",
}
2> Vivek..:
您只需在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
使用提供的代理安装