无法成功下载
Theshy20001201 opened this issue · comments
大佬好!目前遇到的问题是打开learn-stdio之后按照正常流程输入参数运行后程序闪退,之前都没有相关问题(目测应该是更新完新学堂系统导致),请问大佬有解决建议吗~?
下载一下最新的试试?
您好!我试了重新下载最新版本,然后用learn.py,打开之后输入密码账号之后就立马关掉了,没有后续
@erbanku 可以尝试复现一下吗?
您好!我的python和操作系统是Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32。刚才我首先检查了我相关包是否安装好,以下是cmd运行记录,应该都安好了:
C:\Users\林出\Downloads\learn2018-autodown-master (3)\learn2018-autodown-master>pip3 install -r requirements.txt --user -U
Requirement already satisfied: bs4 in c:\users\林出\appdata\roaming\python\python311\site-packages (from -r requirements.txt (line 1)) (0.0.1)
Requirement already satisfied: tqdm in c:\users\林出\appdata\roaming\python\python311\site-packages (from -r requirements.txt (line 2)) (4.66.1)
Requirement already satisfied: requests in c:\users\林出\appdata\roaming\python\python311\site-packages (from -r requirements.txt (line 3)) (2.31.0)
Requirement already satisfied: beautifulsoup4 in c:\users\林出\appdata\roaming\python\python311\site-packages (from bs4->-r requirements.txt (line 1)) (4.12.2)
Requirement already satisfied: colorama in c:\users\林出\appdata\roaming\python\python311\site-packages (from tqdm->-r requirements.txt (line 2)) (0.4.6)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\林出\appdata\roaming\python\python311\site-packages (from requests->-r requirements.txt (line 3)) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in c:\users\林出\appdata\roaming\python\python311\site-packages (from requests->-r requirements.txt (line 3)) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\林出\appdata\roaming\python\python311\site-packages (from requests->-r requirements.txt (line 3)) (2.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\林出\appdata\roaming\python\python311\site-packages (from requests->-r requirements.txt (line 3)) (2023.7.22)
Requirement already satisfied: soupsieve>1.2 in c:\users\林出\appdata\roaming\python\python311\site-packages (from beautifulsoup4->bs4->-r requirements.txt (line 1)) (2.5)
这之后,我又运行了learn.py,显示一下报错,不知道该如何解决,麻烦诸位大佬了~Qwq
C:\Users\林出\Downloads\learn2018-autodown-master (3)\learn2018-autodown-master>learn.py
请输入INFO账号:2023211365
请输入INFO密码:
Traceback (most recent call last):
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1286, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1332, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1281, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1041, in _send_output
self.send(msg)
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 979, in send
self.connect()
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1458, in connect
self.sock = self._context.wrap_socket(self.sock,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1108, in _create
self.do_handshake()
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1379, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1006)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\林出\Downloads\learn2018-autodown-master (3)\learn2018-autodown-master\learn.py", line 36, in open_page
response = opener.open(request)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\林出\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1006)>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\林出\Downloads\learn2018-autodown-master (3)\learn2018-autodown-master\learn.py", line 465, in
main(get_args())
File "C:\Users\林出\Downloads\learn2018-autodown-master (3)\learn2018-autodown-master\learn.py", line 449, in main
args.login = login(username, password)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\林出\Downloads\learn2018-autodown-master (3)\learn2018-autodown-master\learn.py", line 70, in login
info = get_page(login_uri, values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\林出\Downloads\learn2018-autodown-master (3)\learn2018-autodown-master\learn.py", line 43, in get_page
data = open_page(uri, values)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\林出\Downloads\learn2018-autodown-master (3)\learn2018-autodown-master\learn.py", line 39, in open_page
print(uri, e.code, ':', e.reason)
^^^^^^
AttributeError: 'URLError' object has no attribute 'code'
@Theshy20001201
请使用 Python<=3.11.4
试一试,貌似是3.11.5
引入的更新导致此问题,3.11.4
测试成功,3.11.5
失败。
收到,我这就试试!
目前情况是重装一次py 3.11.4+装好相关包之后甚至再也无法成功打开相关learn文件了。。。累觉不爱想放弃了
或许有各位大佬愿意加我微信18227699252指导一下吗qwq没有的话我手动下也行qwq
gpt4:
这个问题出现在尝试打开一个网页时,并且涉及到了 SSL 握手失败和URLError
没有code
属性这个错误。
首先,我们来解决ssl.SSLError: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1006)
这个问题。这个错误是因为 Python 在尝试进行 SSL 握手时遇到了一些问题,有可能是因为目标服务器使用了一些被认为是不安全的旧式 SSL 握手方法。你可以尝试以下解决方案:
- 尝试更新 Python 到最新版本(如果有更新可用的话),有时候这种问题是由于 Python 的某些版本中存在的问题。
- 也可以尝试在代码中禁用 SSL 验证(但是这样做可能会导致安全问题)。你可以尝试在
urllib.request.urlopen
或者requests.get
方法中设置verify
参数为False
来禁用 SSL 验证。
接着,我们需要解决AttributeError: 'URLError' object has no attribute 'code'
这个问题。这个问题是因为你尝试访问URLError
对象的code
属性,但是这个属性不存在。你应该检查e.reason
来了解错误的详情。
我建议你修改你的open_page
函数,使其更加健壮和能够更好地处理错误。你可以这样修改你的代码:
def open_page(uri, values):
try:
data = urllib.parse.urlencode(values).encode('utf-8')
request = urllib.request.Request(uri, data)
response = opener.open(request)
return response.read().decode('utf-8')
except urllib.error.HTTPError as e:
print(f"HTTP Error: {e.code}, URL: {uri}")
return None
except urllib.error.URLError as e:
print(f"URL Error: {e.reason}, URL: {uri}")
return None
except Exception as e:
print(f"Unexpected error: {e}, URL: {uri}")
return None
这样修改后,你的open_page
函数就能够更好地处理各种可能发生的错误了。
希望这能帮到你!如果你还有其他问题或者需要更多的帮助,欢迎随时询问!
@Trinkle23897 我加他了,晚一些会帮他看看
@Trinkle23897 我加他了,晚一些会帮他看看
已解决!
非常感谢!
所以是啥问题?
所以是啥问题?
非脚本问题🤣,而是一些路径中存在中文和权限问题。将脚本移动到不包含中文路径的文件夹中,并以管理员身份运行就解决了。