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

pio remote agent throw's exception on raspberry pi's (5.0.0) #3652

Closed
fietser28 opened this issue Sep 4, 2020 · 7 comments
Closed

pio remote agent throw's exception on raspberry pi's (5.0.0) #3652

fietser28 opened this issue Sep 4, 2020 · 7 comments
Assignees
Milestone

Comments

@fietser28
Copy link

I have a problem running the remote agent on raspberry Pi's with the new 5.0.0:

Configuration

Operating system: Raspbian 10 on Raspberry Pi 4 and Raspbian 9 on Raspberry Pi Zero (tested on both, raspbian 10 is pretty clean, first time PlatformIO installation).

PlatformIO Version (platformio --version): PlatformIO, version 5.0.0

(penv) pi@troel3:~ $ pio system info


PlatformIO Core 5.0.0
Python 3.7.3-final.0
System Type linux_armv7l
Platform Linux-5.4.51-v7l+-armv7l-with-glibc2.28
File System Encoding utf-8
Locale Encoding UTF-8
PlatformIO Core Directory /home/pi/.platformio
PlatformIO Core Executable /home/pi/.platformio/penv/bin/platformio
Python Executable /home/pi/.platformio/penv/bin/python
Global Libraries 0
Development Platforms 0
Tools & Toolchains 2


Description of problem

  • pio remote agent start
  • pio remote agent list
    both will throw an exeption (see below)

pio remote agent
produces the general help text. Other pio commands seem to work ok.

Steps to Reproduce

  1. Do a clean install of platform (wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py; python3 get-platformio.py)
  2. Login with: pio account login (works ok)
  3. start remote agent: pio agent remote start

Actual Results

(penv) pi@troel3:~ $ pio remote agent start [89/395]
Tool Manager: Installing platformio/contrib-pysite @ ~2.37.0
Unpacking [####################################] 100%
Tool Manager: contrib-pysite @ 2.37.191020 has been installed!
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting twisted==20.3.0
Using cached https://www.piwheels.org/simple/twisted/Twisted-20.3.0-cp37-cp37m-linux_armv7l.whl (3.1 MB)
Collecting constantly>=15.1
Using cached constantly-15.1.0-py2.py3-none-any.whl (7.9 kB)
Collecting Automat>=0.3.0
Using cached Automat-20.2.0-py2.py3-none-any.whl (31 kB)
Collecting PyHamcrest!=1.10.0,>=1.9.0
Using cached PyHamcrest-2.0.2-py3-none-any.whl (52 kB)
Collecting hyperlink>=17.1.1
Using cached hyperlink-20.0.1-py2.py3-none-any.whl (48 kB)
Collecting incremental>=16.10.1
Using cached incremental-17.5.0-py2.py3-none-any.whl (16 kB)
Collecting attrs>=19.2.0
Using cached attrs-20.1.0-py2.py3-none-any.whl (49 kB)
Collecting zope.interface>=4.4.2
Using cached https://www.piwheels.org/simple/zope-interface/zope.interface-5.1.0-cp37-cp37m-linux_armv7l.whl (223 kB)
Collecting six
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting idna>=2.5
Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting setuptools
Using cached setuptools-50.2.0-py3-none-any.whl (784 kB)
Installing collected packages: constantly, attrs, six, Automat, PyHamcrest, idna, hyperlink, incremental, setuptools, zope.interface, twisted
Successfully installed Automat-20.2.0 PyHamcrest-2.0.2 attrs-20.1.0 constantly-15.1.0 hyperlink-20.0.1 idna-2.10 incremental-17.5.0 setuptools-50.2.0 six-1.15
.0 twisted-20.3.0 zope.interface-5.1.0
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting autobahn==20.4.3
Using cached autobahn-20.4.3-py2.py3-none-any.whl (1.1 MB)
Collecting cryptography>=2.7
Using cached https://www.piwheels.org/simple/cryptography/cryptography-3.1-cp37-cp37m-linux_armv7l.whl (765 kB)
Collecting txaio>=20.3.1
Using cached txaio-20.4.1-py2.py3-none-any.whl (30 kB)
Collecting six>=1.4.1
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Processing ./.cache/pip/wheels/48/79/c0/d4efbf056e6e79a44346a80938784d462f6a346eea8a47a220/cffi-1.14.2-cp37-cp37m-linux_armv7l.whl
Collecting pycparser
Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Installing collected packages: six, pycparser, cffi, cryptography, txaio, autobahn
Successfully installed autobahn-20.4.3 cffi-1.14.2 cryptography-3.1 pycparser-2.20 six-1.15.0 txaio-20.4.1
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/six.py already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/twisted already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/six-1.15.0.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/bin already exists. Specify --upgrade to force replacement.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting json-rpc==1.13.0
Using cached json_rpc-1.13.0-py2.py3-none-any.whl (41 kB)
Installing collected packages: json-rpc
Successfully installed json-rpc-1.13.0
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyopenssl>=16.0.0
Using cached pyOpenSSL-19.1.0-py2.py3-none-any.whl (53 kB)
Collecting six>=1.5.2
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting cryptography>=2.8
Using cached https://www.piwheels.org/simple/cryptography/cryptography-3.1-cp37-cp37m-linux_armv7l.whl (765 kB)
Processing ./.cache/pip/wheels/48/79/c0/d4efbf056e6e79a44346a80938784d462f6a346eea8a47a220/cffi-1.14.2-cp37-cp37m-linux_armv7l.whl
Collecting pycparser
Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Installing collected packages: six, pycparser, cffi, cryptography, pyopenssl
Successfully installed cffi-1.14.2 cryptography-3.1 pycparser-2.20 pyopenssl-19.1.0 six-1.15.0
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/_cffi_backend.cpython-37m-arm-linux-gnueabihf.so already exists. Specify --upgrade to f
orce replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/pycparser already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/pycparser-2.20.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/six.py already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/cffi already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/cffi-1.14.2.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/cryptography already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/cryptography-3.1.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/six-1.15.0.dist-info already exists. Specify --upgrade to force replacement.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting service_identity>=18.1.0
Using cached service_identity-18.1.0-py2.py3-none-any.whl (11 kB)
Collecting cryptography
Using cached https://www.piwheels.org/simple/cryptography/cryptography-3.1-cp37-cp37m-linux_armv7l.whl (765 kB)
Collecting pyasn1
Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Collecting attrs>=16.0.0
Using cached attrs-20.1.0-py2.py3-none-any.whl (49 kB)
Collecting pyasn1-modules
Using cached pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
Collecting six>=1.4.1
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Processing ./.cache/pip/wheels/48/79/c0/d4efbf056e6e79a44346a80938784d462f6a346eea8a47a220/cffi-1.14.2-cp37-cp37m-linux_armv7l.whl
Collecting pycparser
Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Installing collected packages: six, pycparser, cffi, cryptography, pyasn1, attrs, pyasn1-modules, service-identity
Successfully installed attrs-20.1.0 cffi-1.14.2 cryptography-3.1 pyasn1-0.4.8 pyasn1-modules-0.2.8 pycparser-2.20 service-identity-18.1.0 six-1.15.0
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/_cffi_backend.cpython-37m-arm-linux-gnueabihf.so already exists. Specify --upgrade to f
orce replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/pycparser already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/attrs-20.1.0.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/pycparser-2.20.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/six.py already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/cffi already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/cffi-1.14.2.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/cryptography already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/cryptography-3.1.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/attr already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/six-1.15.0.dist-info already exists. Specify --upgrade to force replacement.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting idna!=2.3,>=0.6
Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Installing collected packages: idna
Successfully installed idna-2.10
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/idna already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/idna-2.10.dist-info already exists. Specify --upgrade to force replacement.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting zeroconf==0.26.0
Using cached zeroconf-0.26.0-py3-none-any.whl (67 kB)
Collecting ifaddr
Using cached ifaddr-0.1.7-py2.py3-none-any.whl (10 kB)
Installing collected packages: ifaddr, zeroconf
Successfully installed ifaddr-0.1.7 zeroconf-0.26.0
Error: Traceback (most recent call last):
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/main.py", line 109, in main
cli() # pylint: disable=no-value-for-parameter
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/commands/init.py", line 44, in invoke
return super(PlatformioCLI, self).invoke(ctx)
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/commands/remote/command.py", line 66, in remote_agent_start
from platformio.commands.remote.client.agent_service import RemoteAgentService
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/commands/remote/client/agent_service.py", line 25, in
from platformio.commands.remote.client.base import RemoteClientBase
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/commands/remote/client/base.py", line 30, in
from platformio.commands.remote.factory.ssl import SSLContextFactory
File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/commands/remote/factory/ssl.py", line 16, in
from OpenSSL import SSL # pylint: disable=import-error
File "/home/pi/.platformio/packages/contrib-pysite/OpenSSL/init.py", line 8, in
from OpenSSL import crypto, SSL
File "/home/pi/.platformio/packages/contrib-pysite/OpenSSL/crypto.py", line 12, in
from cryptography import x509
File "/home/pi/.platformio/packages/contrib-pysite/cryptography/x509/init.py", line 8, in
from cryptography.x509.base import (
File "/home/pi/.platformio/packages/contrib-pysite/cryptography/x509/base.py", line 15, in
from cryptography.hazmat.backends import _get_backend
ImportError: cannot import name '_get_backend' from 'cryptography.hazmat.backends' (/home/pi/.platformio/packages/contrib-pysite/cryptography/hazmat/backends/
init.py)

============================================================

An unexpected error occurred. Further steps:

============================================================

Expected Results

Not an exception but a running agent. :-)

Additional info

  • Every time I run a pio remote ... command the package installations shown above are executed. Normally I expect this to run only once after an installation/upgrade. I have no explanation why this happens, probably because of the exception?

  • Tried several things including install additional libraries and or -dev packages or adding packages manually (pip install ..). No difference at all.

  • The method that throws the error is present in the .py file. Doesn't look strange either, but I'm not very experienced with python.

  • activating penv or not makes no difference.

Did I still miss something or is this a bug?

@fietser28
Copy link
Author

dpkg-l.txt

dpkg -l list off mentioned pi4 with raspbian 10.4

@liebman
Copy link

liebman commented Sep 5, 2020

I have the same exact issue on a pi3 :-(

(penv) pi@lab:~ $ pio system info
--------------------------  ----------------------------------------
PlatformIO Core             5.0.0
Python                      3.7.3-final.0
System Type                 linux_armv7l
Platform                    Linux-4.19.97-v7+-armv7l-with-glibc2.28
File System Encoding        utf-8
Locale Encoding             UTF-8
PlatformIO Core Directory   /home/pi/.platformio
PlatformIO Core Executable  /home/pi/.platformio/penv/bin/platformio
Python Executable           /home/pi/.platformio/penv/bin/python
Global Libraries            0
Development Platforms       0
Tools & Toolchains          1
--------------------------  ----------------------------------------

@BertvanHoekelen
Copy link

I also have this issue on the rpi 4 with ubuntu server.

--------------------------  ---------------------------------------------
PlatformIO Core             5.0.0
Python                      3.8.2-final.0
System Type                 linux_aarch64
Platform                    Linux-5.4.0-1016-raspi-aarch64-with-glibc2.29
File System Encoding        utf-8
Locale Encoding             UTF-8
PlatformIO Core Directory   /home/ubuntu/.platformio
PlatformIO Core Executable  /home/ubuntu/.platformio/penv/bin/platformio
Python Executable           /home/ubuntu/.platformio/penv/bin/python
Global Libraries            0
Development Platforms       0
Tools & Toolchains          2
--------------------------  ---------------------------------------------

@j2thex
Copy link

j2thex commented Sep 6, 2020

same.... How can this be fixed?

@ivankravets
Copy link
Member

This is an issue with Cryptography pre-built binaries. I opened an issue pyca/cryptography#5455

In any case, we did a workaround on our side. Could you performa the next commands?

  1. pio upgrade --dev
  2. pio home

It should recompile evrything from source. Does it work now?

@fietser28
Copy link
Author

It works on my Pi4 with raspbian 10.4. Will start the build on the Pi Zero tonight, rebuilding everything on a Pi Zero is very slow.

The first time I tried 'pio remote agent start' it failed, but all on subsequent attempts it worked. Commands like remote upload and device list also work fine now.

Thanks for the workaround! Keep up this amazing work.

@fietser28
Copy link
Author

It also works on my Pi Zero with Raspbian 9. First time I ran 'pio remote agent start' it failed, second time it worked.

I also tried to remove the python3-cryptography packages (v1.7.1) and install cryptography thru pip (v3.1), but that didn't work for me (I'm not very proficient in python/pip package management, although I learned a lot the last few days.)

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

No branches or pull requests

5 participants