Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

树莓派下运行源代码出现问题 #143

Open
zyftank opened this issue Apr 1, 2019 · 45 comments
Open

树莓派下运行源代码出现问题 #143

zyftank opened this issue Apr 1, 2019 · 45 comments
Assignees

Comments

@zyftank
Copy link
Contributor

zyftank commented Apr 1, 2019

本想着提交下树莓派下编译文件,可是运行新版本的源代码时出错,以下是错误信息,求问题原因。
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/home/pi/learn/Source Packages/pdlearn/threads.py", line 23, in run
self.func(self.args)
File "pandalearning.py", line 130, in video
driver_video.go_js('window.scrollTo(0, document.body.scrollHeight/180
{})'.format(j))
File "/home/pi/learn/Source Packages/pdlearn/mydriver.py", line 96, in go_js
self.driver.execute_script(js)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
'args': converted_args})['value']
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from tab crashed
(Session info: headless chrome=72.0.3626.121)
(Driver info: chromedriver=72.0.3626.121,platform=Linux 4.14.79-v7+ armv7l)

出问题的代码是在学习视频的线程中,文章是可以正常学习的。

@noway2014
Copy link

希望树莓派编译的,等待楼上

@zyftank
Copy link
Contributor Author

zyftank commented Apr 1, 2019

终于弄好了

@WenhaoDaiCN
Copy link
Owner

终于弄好了

@zyftank 👍

@zyftank
Copy link
Contributor Author

zyftank commented Apr 1, 2019

@ALIVON 问题是解决了,但是我还是有疑问的,学习文章和视频的代码都差不多,为什么就视频的程序在go_js这个函数上过不去呢,只有将视频的模式改成nohead=False程序才能运行?

@WenhaoDaiCN
Copy link
Owner

是不是树莓派资源到账,我没有设备也不能测试🙃

@zyftank
Copy link
Contributor Author

zyftank commented Apr 2, 2019

@ALIVON 已经pull了,这是个问题,感觉vps能行的,树莓派也能运行,只是树莓派的匹配的chrome和chromedriver资源不好找而已,自己动手能力强点的应该会自己调试源码的,不行的话,我pull个树莓派的源码,配合一下使用说明就能使用。

@WenhaoDaiCN
Copy link
Owner

@ALIVON 已经pull了,这是个问题,感觉vps能行的,树莓派也能运行,只是树莓派的匹配的chrome和chromedriver资源不好找而已,自己动手能力强点的应该会自己调试源码的,不行的话,我pull个树莓派的源码,配合一下使用说明就能使用。

@zyftank 有无加入--disable-gpu
chrome_options.add_argument('--disable-gpu')
用用单线程跑呢

@WenhaoDaiCN
Copy link
Owner

@ALIVON 已经pull了,这是个问题,感觉vps能行的,树莓派也能运行,只是树莓派的匹配的chrome和chromedriver资源不好找而已,自己动手能力强点的应该会自己调试源码的,不行的话,我pull个树莓派的源码,配合一下使用说明就能使用。

@zyftank 有无加入--disable-gpu
chrome_options.add_argument('--disable-gpu')
用用单线程跑呢

后面慢慢更新文档加入下载和贡献

@icman02200459
Copy link

大佬们 那个安装下载安装铬和chromedriver及XVFB
1.下载网址:HTTPS://mirrors.tuna.tsinghua.edu.cn/raspberrypi/pool/main/c/chromium-browser/
下载铬浏览器的l10n_72.0.3626.121-0 + rpt3_all.deb和铬chromedriver_72.0.3626.121-0 + rpt3_armhf.deb
这一步看不太懂 ,大佬可以提示一下怎么学习么

@icman02200459
Copy link

软件包体系架构(amd64)与本机系统体系结构(armhf)不符
在处理时有错误发生:
这怎么解决

@zyftank
Copy link
Contributor Author

zyftank commented Apr 8, 2019

@icman02200459 你在哪下的软件包,下载网址,你复制一下,粘贴一下进浏览器地址栏里回车,就可以进入清华镜像源的下载页面,找到你需要的软件下载就行了。

@isping
Copy link

isping commented Apr 12, 2019

楼主问题我也遇到了,请问如何解决的视频学习问题

@mr-zl
Copy link

mr-zl commented Apr 17, 2019

源码可以执行,打包后不能执行,不知道什么问题

错误提示

Traceback (most recent call last):
File "pandalearning.py", line 4, in
File "/usr/local/lib/python3.5/dist-packages/PyInstaller-3.5.dev0+b54a15d72e-py3.5.egg/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.dict)
File "pdlearn/version.py", line 1, in
File "/usr/local/lib/python3.5/dist-packages/PyInstaller-3.5.dev0+b54a15d72e-py3.5.egg/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.dict)
File "requests/init.py", line 63, in
File "/usr/local/lib/python3.5/dist-packages/PyInstaller-3.5.dev0+b54a15d72e-py3.5.egg/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.dict)
File "requests/utils.py", line 24, in
File "/usr/local/lib/python3.5/dist-packages/PyInstaller-3.5.dev0+b54a15d72e-py3.5.egg/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.dict)
File "requests/_internal_utils.py", line 11, in
File "/usr/local/lib/python3.5/dist-packages/PyInstaller-3.5.dev0+b54a15d72e-py3.5.egg/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.dict)
File "requests/compat.py", line 11, in
ImportError: cannot import name 'chardet'
[10929] Failed to execute script pandalearning

@zyftank
Copy link
Contributor Author

zyftank commented Apr 17, 2019

楼上的,打包的时候有些引用的包没打进去。

@mr-zl
Copy link

mr-zl commented Apr 17, 2019

楼上的,打包的时候有些引用的包没打进去。

向大佬请教,有空的话指导一下

@zyftank
Copy link
Contributor Author

zyftank commented Apr 17, 2019

我记得当时是编辑spec文件的方法解决的,先正常用pyinstaller打包一遍,而后编辑后缀为spec文件,在hiddenimports的后面,加上缺少的包名字,本例是chardet,在执行一下pyinstaller -D XXX.SPEC试试。

还有种方法是指定第三方库目录路径,pyinstaller -F -p /dir;/dir2 xxx.py 注意dir和dir2是路径。

@mr-zl
Copy link

mr-zl commented Apr 17, 2019

我记得当时是编辑spec文件的方法解决的,先正常用pyinstaller打包一遍,而后编辑后缀为spec文件,在hiddenimports的后面,加上缺少的包名字,本例是chardet,在执行一下pyinstaller -D XXX的.spec试试。

还有种方法是指定第三方库目录路径,pyinstaller -F -p / dir; / dir2 xxx.py注意dir和dir2是路径。

按大佬说的方法,在hiddenimports后加上chardet后,重新pyinstall sepc后可以成功运行,输入账号密码后较长时间显示正在登陆,然后是下面的错误提示:
Traceback (most recent call last):
File "pandalearning.py", line 180, in
File "pandalearning.py", line 21, in user_flag
File "pdlearn/dingding.py", line 27, in dd_login_status
File "pdlearn/mydriver.py", line 111, in get_cookies
File "selenium/webdriver/remote/webdriver.py", line 841, in get_cookies
File "selenium/webdriver/remote/webdriver.py", line 321, in execute
File "selenium/webdriver/remote/errorhandler.py", line 242, in check_response
selenium.common.exceptions.TimeoutException: Message: timeout
(Session info: headless chrome=72.0.3626.121)
(Driver info: chromedriver=72.0.3626.121,platform=Linux 4.14.98-v7+ armv7l)

[12127] Failed to execute script pandalearning

@zyftank
Copy link
Contributor Author

zyftank commented Apr 17, 2019

你编我的源码吧,Alivon的源码在树莓派下出点小问题的,我已经改过了。

@mr-zl
Copy link

mr-zl commented Apr 18, 2019

你编我的源码吧,Alivon的源码在树莓派下出点小问题的,我已经改过了。

刚刚试了一下你的,源码不能运行

@zyftank
Copy link
Contributor Author

zyftank commented Apr 18, 2019

贴一下运行错误的提示。

@mr-zl
Copy link

mr-zl commented Apr 18, 2019

贴一下运行错误的提示。

Traceback (most recent call last):
File "/home/pi/Downloads/pi/Learning-master/learn.py", line 12, in
from pyvirtualdisplay import Display
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 305, in _custom_import
module = self._original_import(*args, **kw)
ImportError: No module named 'pyvirtualdisplay'

@zyftank
Copy link
Contributor Author

zyftank commented Apr 18, 2019

pip3 install pyvirtualdisplay
以后碰到no module named XXX错误,安装缺少的包就对了。

@mr-zl
Copy link

mr-zl commented Apr 18, 2019

pip3安装pyvirtualdisplay
以后碰到没有名为XXX错误的模块,安装缺少的包就对了。

好的,感谢大佬教导

@mr-zl
Copy link

mr-zl commented Apr 18, 2019

安装了pyvirtualdisplay ,还是一样的错误提示

@zyftank
Copy link
Contributor Author

zyftank commented Apr 18, 2019

你用的python还是python3?如果用pip3安装,就用python3运行源代码,如果用pip安装,就用python运行,或者用pip,pip3都安装一下,确定包是否安装好。

@mr-zl
Copy link

mr-zl commented Apr 19, 2019

你用的蟒蛇还是python3?如果用PIP3安装,就用python3运行源代​​码,如果用PIP安装,就用python的运行,或者用PIP,PIP 3都安装一下,确定包是否安装好。

pip3安装都没成功,pip成功了,但是用python运行还是提示缺少模块

@zyftank
Copy link
Contributor Author

zyftank commented Apr 19, 2019

用pip3装,装的时候可能有点蛋疼,用python2运行又要改代码,你先升级一下pip3,百度树莓派+pip3升级,可能会出错,找找应该有解决办法。

@mr-zl
Copy link

mr-zl commented Apr 19, 2019

确实很蛋疼,还在找方法,还好大佬耐心指导,不然真想放弃了

@mr-zl
Copy link

mr-zl commented Apr 19, 2019

用PIP3装,装的时候可能有点蛋疼,用python2运行又要改代码,你先升级一下PIP3,百度树莓派+ PIP3升级,可能会出错,找找应该有解决办法。

还是搞不定,升级pip3之后报ImportError: cannot import name 'main'。按网上教程修改usr/bin/pip3文件后执行 sudo pip3 install pyvirtualdispla
报错:Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyvirtualdispla
Could not find a version that satisfies the requirement pyvirtualdispla (from versions: )
No matching distribution found for pyvirtualdispla

@zyftank
Copy link
Contributor Author

zyftank commented Apr 19, 2019

你包名字搞错了

@zyftank
Copy link
Contributor Author

zyftank commented Apr 19, 2019

别急,把这次搞成功了,后面碰到问题,你就不怎么怕了,关键用好度娘和google搜索工具。一次搞不定,休息休息,下次再搞也许就有好的方法。

@zyftank
Copy link
Contributor Author

zyftank commented Apr 19, 2019

我特意卸载了一下,可以使用命令sudo pip3 install pyvirtualdisplay 安装依赖包。我的pip3版本9.0.1

@zyftank
Copy link
Contributor Author

zyftank commented Apr 19, 2019

@mr-zl
Copy link

mr-zl commented Apr 19, 2019

我特意卸载了一下,使用命令sudo pip3 install pyvirtualdisplay安装依赖包。我的pip3版本9.0.1

再次感谢大佬的耐心教导,真是遇到的第一个这么有耐心的。
重卸载pip和pip3后,重新安装pip3,然后sudo pip3 install pyvirtualdisplay成功安装 pyvirtualdisplay,再运行你的源码,可以运行,显示登陆中一会,然后提示下列错误:
Traceback (most recent call last):
File "learn.py", line 180, in
cookies, a_log, v_log = user_flag(dd_status, uname)
File "learn.py", line 23, in user_flag
cookies = dingding.dd_login_status(uname)
File "/home/pi/Downloads/pi/Learning-master/pdlearn/dingding.py", line 27, in dd_login_status
cookies = driver_login.get_cookies()
File "/home/pi/Downloads/pi/Learning-master/pdlearn/mydriver.py", line 85, in get_cookies
cookies = self.driver.get_cookies()
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 841, in get_cookies
return self.execute(Command.GET_ALL_COOKIES)['value']
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout
(Session info: headless chrome=72.0.3626.121)
(Driver info: chromedriver=72.0.3626.121,platform=Linux 4.14.98-v7+ armv7l)
然后尝试Alivon的源码,也是不能运行了,提示以下错误:
Traceback (most recent call last):
File "pandalearning.py", line 180, in
cookies, a_log, v_log = user_flag(dd_status, uname)
File "pandalearning.py", line 15, in user_flag
cookies = dingding.dd_login_status(uname, has_dd=True)
File "/home/pi/Downloads/Panda-Learning-master/Source Packages/pdlearn/dingding.py", line 27, in dd_login_status
cookies = driver_login.get_cookies()
File "/home/pi/Downloads/Panda-Learning-master/Source Packages/pdlearn/mydriver.py", line 111, in get_cookies
cookies = self.driver.get_cookies()
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 841, in get_cookies
return self.execute(Command.GET_ALL_COOKIES)['value']
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout
(Session info: headless chrome=72.0.3626.121)
(Driver info: chromedriver=72.0.3626.121,platform=Linux 4.14.98-v7+ armv7l)

@zyftank
Copy link
Contributor Author

zyftank commented Apr 19, 2019

从错误提示上看跟程序没关系,你检查一下网络。

@mr-zl
Copy link

mr-zl commented Apr 21, 2019

现在终于可以运行了,但是有一个问题,用你的源码不能多用户

@orange-soda
Copy link

根据使用说明成功搭建了环境,但是存在一个问题,就是drver在sendkeys的过程中,无法输入数字5,输入的是一个退格。因为账号里有“5”,这就导致我登陆不了。不知道有否遇到同样问题的,或者能帮我测试一下的。

@zyftank
Copy link
Contributor Author

zyftank commented May 8, 2019

根据使用说明成功搭建了环境,但是存在一个问题,就是drver在sendkeys的过程中,无法输入数字5,输入的是一个退格。因为账号里有“5”,这就导致我登陆不了。不知道有否遇到同样问题的,或者能帮我测试一下的。

send_keys问题,主要是那两个input输入框,要改变属性,或者模拟点击,如果不成功,可能是没点击好,我以前有个版本是改属性,也可以send_keys成功,现在找不到了。你把代码传到你的github上才能帮你测试啊。

@VisionBao
Copy link

@zyftank 我出的问题和你一样 即便是nohead=False也不可以

Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/home/pi/learn/Source Packages/pdlearn/threads.py", line 23, in run
self.func(self.args)
File "pandalearning.py", line 130, in video
driver_video.go_js('window.scrollTo(0, document.body.scrollHeight/180{})'.format(j))
File "/home/pi/learn/Source Packages/pdlearn/mydriver.py", line 96, in go_js
self.driver.execute_script(js)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
'args': converted_args})['value']
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from tab crashed
(Session info: headless chrome=72.0.3626.121)
(Driver info: chromedriver=72.0.3626.121,platform=Linux 4.14.79-v7+ armv7l)

很尴尬 不了解py 不知道如何解决

@zyftank
Copy link
Contributor Author

zyftank commented May 9, 2019

@VisionBao 你用我的代码试试,learn

@zyftank 我出的问题和你一样 即便是nohead=False也不可以

Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/home/pi/learn/Source Packages/pdlearn/threads.py", line 23, in run
self.func(self.args)
File "pandalearning.py", line 130, in video
driver_video.go_js('window.scrollTo(0, document.body.scrollHeight/180{})'.format(j))
File "/home/pi/learn/Source Packages/pdlearn/mydriver.py", line 96, in go_js
self.driver.execute_script(js)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
'args': converted_args})['value']
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from tab crashed
(Session info: headless chrome=72.0.3626.121)
(Driver info: chromedriver=72.0.3626.121,platform=Linux 4.14.79-v7+ armv7l)

很尴尬 不了解py 不知道如何解决

@VisionBao
Copy link

@zyftank 你的可以,但是差别在哪呢? 既然owner已经升级 2.5 你的版本还是2.3 是否可以同步一起升级呢 或者是我如何修改就可以通用了呢?

@VisionBao
Copy link

VisionBao commented May 9, 2019

@zyftank 照着你的思路改过之后发现 文章,视频居然有弹窗了,不知道为何,还请大神赐教一下.如何去除这个弹窗

@zyftank
Copy link
Contributor Author

zyftank commented May 9, 2019

@VisionBao 我的代码是为无桌面系统改的,你有桌面,直接用原版的即可。其实改动不多,自己可以对比一下。

@jwc19890114
Copy link

为什么无法更新呀

@signup-github
Copy link

树莓派3B+执行Dockerfile,报错信息如下:

Sending build context to Docker daemon 4.097MB
Step 1/30 : FROM alpine AS builder
---> 3e8172af00ce
Step 2/30 : ENV QEMU_URL https://github.com/balena-io/qemu/releases/download/v3.0.0%2Bresin/qemu-3.0.0+resin-arm.tar.gz
---> Using cache
---> d6cb1a3a3a2d
Step 3/30 : RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
---> Using cache
---> 7024d824fbd7
Step 4/30 : RUN apk add curl && curl -L ${QEMU_URL} | tar zxvf - -C . --strip-components 1
---> Running in baa8322b003a
fetch https://mirrors.ustc.edu.cn/alpine/v3.14/main/armv7/APKINDEX.tar.gz
ERROR: https://mirrors.ustc.edu.cn/alpine/v3.14/main: temporary error (try again later)
WARNING: Ignoring https://mirrors.ustc.edu.cn/alpine/v3.14/main: No such file or directory
fetch https://mirrors.ustc.edu.cn/alpine/v3.14/community/armv7/APKINDEX.tar.gz
1995801488:error:0D0D90AD:asn1 encoding routines:ASN1_TIME_adj:error getting time:crypto/asn1/a_time.c:330:
1995801488:error:0D0D90AD:asn1 encoding routines:ASN1_TIME_adj:error getting time:crypto/asn1/a_time.c:330:
1995801488:error:0D0D90AD:asn1 encoding routines:ASN1_TIME_adj:error getting time:crypto/asn1/a_time.c:330:
1995801488:error:0D0D90AD:asn1 encoding routines:ASN1_TIME_adj:error getting time:crypto/asn1/a_time.c:330:
1995801488:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1914:
ERROR: https://mirrors.ustc.edu.cn/alpine/v3.14/community: Permission denied
WARNING: Ignoring https://mirrors.ustc.edu.cn/alpine/v3.14/community: No such file or directory
ERROR: unable to select packages:
curl (no such package):
required by: world[curl]
The command '/bin/sh -c apk add curl && curl -L ${QEMU_URL} | tar zxvf - -C . --strip-components 1' returned a non-zero code: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants