Pio agent fails to install or run - Raspbian buster

Happy to re-test, will report back.

Still failing after a: pio upgrade --dev
(please disregard my mangled prompt, it’s the venv)

(penv) β”Œ[pi@octopi]
β””[~/.platformio/penv/bin]> pio --version
PlatformIO Core, version 5.2.4a4
(penv) β”Œ[pi@octopi]
β””[~/.platformio/penv/bin]> pio upgrade --dev
Please wait while upgrading PlatformIO ...
PlatformIO has been successfully upgraded to 5.2.4a4
Release notes: https://docs.platformio.org/en/latest/history.html
(penv) β”Œ[pi@octopi]
β””[~/.platformio/penv/bin]> pio --version
PlatformIO Core, version 5.2.4a4
(penv) β”Œ[pi@octopi]
β””[~/.platformio/penv/bin]> pio remote agent start
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 Twisted-20.3.0.tar.bz2 (3.1 MB)
  Preparing metadata (setup.py) ... done
Collecting zope.interface>=4.4.2
  Using cached zope.interface-5.4.0.tar.gz (249 kB)
  Preparing metadata (setup.py) ... done
Collecting constantly>=15.1
  Using cached constantly-15.1.0.tar.gz (21 kB)
  Preparing metadata (setup.py) ... done
Collecting incremental>=16.10.1
  Using cached incremental-21.3.0.tar.gz (17 kB)
  Preparing metadata (setup.py) ... done
Collecting Automat>=0.3.0
  Using cached Automat-20.2.0.tar.gz (61 kB)
  Preparing metadata (setup.py) ... done
Collecting hyperlink>=17.1.1
  Using cached hyperlink-21.0.0.tar.gz (140 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting PyHamcrest!=1.10.0,>=1.9.0
  Using cached PyHamcrest-2.0.2.tar.gz (44 kB)
  Preparing metadata (setup.py) ... done
Collecting attrs>=19.2.0
  Using cached attrs-21.2.0.tar.gz (184 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting six
  Using cached six-1.16.0.tar.gz (34 kB)
  Preparing metadata (setup.py) ... done
Collecting idna>=2.5
  Using cached idna-3.3.tar.gz (286 kB)
  Preparing metadata (setup.py) ... done
Collecting setuptools
  Using cached setuptools-59.4.0.tar.gz (2.3 MB)
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Skipping wheel build for twisted, due to binaries being disabled for it.
Skipping wheel build for Automat, due to binaries being disabled for it.
Skipping wheel build for constantly, due to binaries being disabled for it.
Skipping wheel build for incremental, due to binaries being disabled for it.
Skipping wheel build for PyHamcrest, due to binaries being disabled for it.
Skipping wheel build for zope.interface, due to binaries being disabled for it.
Skipping wheel build for idna, due to binaries being disabled for it.
Skipping wheel build for six, due to binaries being disabled for it.
Building wheels for collected packages: attrs, hyperlink, setuptools
  Building wheel for attrs (pyproject.toml) ... done
  Created wheel for attrs: filename=attrs-21.2.0-py2.py3-none-any.whl size=53741 sha256=efe744a6b18b2e9734a4881d11aac9889085dade2a50f09bdc26d79d520b9547
  Stored in directory: /home/pi/.cache/pip/wheels/16/c5/10/f4f3745d449d987c88878f0327089a3a275362a633e05b0d95
  Building wheel for hyperlink (pyproject.toml) ... done
  Created wheel for hyperlink: filename=hyperlink-21.0.0-py2.py3-none-any.whl size=74653 sha256=f66acdd1bdcf8fc1862f196ca8d1f362b9666ff96a1405ffb22e5abf36451653
  Stored in directory: /home/pi/.cache/pip/wheels/88/de/19/cb72b4d9352212aa72590f091be9d29c2ae597def937977879
  Building wheel for setuptools (pyproject.toml) ... done
  Created wheel for setuptools: filename=setuptools-59.4.0-py3-none-any.whl size=952264 sha256=2de75a4100400761623ce90c062c13fe90af2dcb473b806977b0dde3f1074602
  Stored in directory: /home/pi/.cache/pip/wheels/ac/67/ef/5b498bb68bb8d4a0ce76b97e2c9a42c97a9f910ae468038f28
Successfully built attrs hyperlink setuptools
Installing collected packages: six, setuptools, idna, attrs, zope.interface, PyHamcrest, incremental, hyperlink, constantly, Automat, twisted
    Running setup.py install for six ... done
    Running setup.py install for idna ... done
    Running setup.py install for zope.interface ... done
    Running setup.py install for PyHamcrest ... done
    Running setup.py install for incremental ... done
    Running setup.py install for constantly ... done
    Running setup.py install for Automat ... done
    Running setup.py install for twisted ... done
Successfully installed Automat-20.2.0 PyHamcrest-2.0.2 attrs-21.2.0 constantly-15.1.0 hyperlink-21.0.0 idna-3.3 incremental-21.3.0 setuptools-59.4.0 six-1.16.0 twisted-20.3.0 zope.interface-5.4.0
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting cryptography==3.3.2
  Downloading cryptography-3.3.2.tar.gz (539 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 539 kB 3.0 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting six>=1.4.1
  Using cached six-1.16.0.tar.gz (34 kB)
  Preparing metadata (setup.py) ... done
Collecting cffi>=1.12
  Using cached cffi-1.15.0.tar.gz (484 kB)
  Preparing metadata (setup.py) ... done
Collecting pycparser
  Using cached pycparser-2.21.tar.gz (170 kB)
  Preparing metadata (setup.py) ... done
Skipping wheel build for cffi, due to binaries being disabled for it.
Skipping wheel build for six, due to binaries being disabled for it.
Skipping wheel build for pycparser, due to binaries being disabled for it.
Building wheels for collected packages: cryptography
  Building wheel for cryptography (pyproject.toml) ... done
  Created wheel for cryptography: filename=cryptography-3.3.2-cp37-cp37m-linux_armv7l.whl size=782125 sha256=7ce4e4048694ed234237930df8a68eccc1787b6bdb09b6759d0f1392a5f24254
  Stored in directory: /home/pi/.cache/pip/wheels/b5/85/11/f80434ce4d816945abc9d79690a1064f750862de7bc9888908
Successfully built cryptography
Installing collected packages: pycparser, six, cffi, cryptography
    Running setup.py install for pycparser ... done
    Running setup.py install for six ... done
    Running setup.py install for cffi ... done
Successfully installed cffi-1.15.0 cryptography-3.3.2 pycparser-2.21 six-1.16.0
WARNING: Target directory /home/pi/.platformio/packages/contrib-pysite/six-1.16.0-py3.7.egg-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.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyopenssl>=16.0.0
  Downloading pyOpenSSL-21.0.0.tar.gz (175 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 175 kB 2.8 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting six>=1.5.2
  Using cached six-1.16.0.tar.gz (34 kB)
  Preparing metadata (setup.py) ... done
Collecting cryptography>=3.3
  Downloading cryptography-36.0.0.tar.gz (571 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 571 kB 41 kB/s
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /home/pi/.platformio/penv/bin/python /tmp/pip-standalone-pip-44rut6sr/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-nmvajd5v/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"'' 'setuptools-rust>=0.11.4'
       cwd: None
  Complete output (31 lines):
  Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://www.piwheels.org/simple
  Collecting setuptools>=40.6.0
    Using cached setuptools-59.4.0.tar.gz (2.3 MB)
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Installing backend dependencies: started
    Installing backend dependencies: finished with status 'done'
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status 'done'
  Collecting wheel
    Using cached wheel-0.37.0.tar.gz (65 kB)
    Preparing metadata (setup.py): started
    Preparing metadata (setup.py): finished with status 'done'
  Collecting cffi>=1.12
    Using cached cffi-1.15.0.tar.gz (484 kB)
    Preparing metadata (setup.py): started
    Preparing metadata (setup.py): finished with status 'done'
  Collecting setuptools-rust>=0.11.4
    Using cached setuptools-rust-1.0.0.tar.gz (279 kB)
    Installing build dependencies: started
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
  ERROR: Some build dependencies for setuptools-rust>=0.11.4 from https://files.pythonhosted.org/packages/22/fa/ac431f0571bd84d8da5b55d9c9a00d510ae8682324405eabd96a752d090c/setuptools-rust-1.0.0.tar.gz#sha256=eb6e6d41f01e63d042288e5c609684adf93426c10ea745ec324263f3fcbf27e9 conflict with the backend dependencies: setuptools_scm==6.0.1 is incompatible with setuptools_scm>=6.3.2.
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/60/06/d9109aba62c0b42466195e5b9b30dded26621a675b73998218070d8cc637/cryptography-36.0.0.tar.gz#sha256=52f769ecb4ef39865719aedc67b4b7eae167bafa48dbc2a26dd36fa56460507f (from https://pypi.org/simple/cryptography/) (requires-python:>=3.6). Command errored out with exit status 1: /home/pi/.platformio/penv/bin/python /tmp/pip-standalone-pip-44rut6sr/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-nmvajd5v/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"'' 'setuptools-rust>=0.11.4' Check the logs for full command output.
  Downloading cryptography-35.0.0.tar.gz (559 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 559 kB 2.4 MB/s
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /home/pi/.platformio/penv/bin/python /tmp/pip-standalone-pip-nr8agkuv/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-q9q2qid9/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"'' 'setuptools-rust>=0.11.4'
       cwd: None
  Complete output (31 lines):
  Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://www.piwheels.org/simple
  Collecting setuptools>=40.6.0
    Using cached setuptools-59.4.0.tar.gz (2.3 MB)
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Installing backend dependencies: started
    Installing backend dependencies: finished with status 'done'
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status 'done'
  Collecting wheel
    Using cached wheel-0.37.0.tar.gz (65 kB)
    Preparing metadata (setup.py): started
    Preparing metadata (setup.py): finished with status 'done'
  Collecting cffi>=1.12
    Using cached cffi-1.15.0.tar.gz (484 kB)
    Preparing metadata (setup.py): started
    Preparing metadata (setup.py): finished with status 'done'
  Collecting setuptools-rust>=0.11.4
    Using cached setuptools-rust-1.0.0.tar.gz (279 kB)
    Installing build dependencies: started
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: still running...
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
  ERROR: Some build dependencies for setuptools-rust>=0.11.4 from https://files.pythonhosted.org/packages/22/fa/ac431f0571bd84d8da5b55d9c9a00d510ae8682324405eabd96a752d090c/setuptools-rust-1.0.0.tar.gz#sha256=eb6e6d41f01e63d042288e5c609684adf93426c10ea745ec324263f3fcbf27e9 conflict with the backend dependencies: setuptools_scm==6.0.1 is incompatible with setuptools_scm>=6.3.2.
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/10/91/90b8d4cd611ac2aa526290ae4b4285aa5ea57ee191c63c2f3d04170d7683/cryptography-35.0.0.tar.gz#sha256=9933f28f70d0517686bd7de36166dda42094eac49415459d9bdf5e7df3e0086d (from https://pypi.org/simple/cryptography/) (requires-python:>=3.6). Command errored out with exit status 1: /home/pi/.platformio/penv/bin/python /tmp/pip-standalone-pip-nr8agkuv/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-q9q2qid9/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"'' 'setuptools-rust>=0.11.4' Check the logs for full command output.
  Using cached cryptography-3.4.8.tar.gz (546 kB)
  Installing build dependencies ... \^canceled
ERROR: Operation cancelled by user

Aborted!

This appears to be the same issue as this topic. I just did a pio upgrade --dev, but so far no change (it’s taking over an hour). I still see rustc runs on all 4 cores, driving the RasPi3 to the max - so it looks like pio 5.2.4a4 still triggers & needs rust.

Update - to follow up, yep similar error:

ImportError: The version of cryptography does not match the loaded shared object. This can happen if you have multiple copies of cryptography installed in your Python path. Please try creating a new virtual environment to resolve this issue. Loaded python version: 3.1.1, shared object version: b’3.3.2’

I see several versions of cryptography getting built (pulling all its dependencies in, each time) - and then after a while these end up leading the the above error. Lots of heavy rust builds, for sure. I could do a complete PlatformIO reinstall on this RasPi, if that is of any use, but in that case please let me know which exact install method to use.

Any idea how we can work around this? Should a complete reinstall of PIO be performed, if so how should it be done?

I don’t know, am not using pio remote for the time being.
I’m hoping someone else will chime in.

Could you try to run from PIO Python virtual environment?

pip install "cryptography >= 3.3, < 35.0.0"

Hello everybody,

as @xstrex I’m also a long time pio user and this is my first real problem I came across.
My setup is debian bullseye on RPI4 and I had the same issue. pio remote agent start downloaded a lot of packages and compiled on cryptography within a loop trying to download older versions starting from 3.4.8.

I found a somewhat more β€œhacky and dirty” solution, at least I was able to get the remote agent to work again:
I explored a bit whats happening and saw that during this process pip is called with the --no-binary option.
I looked this argument construction up in platformio/package/manager/core.py in build_contrib_pysite_package() and removed the argument adding of β€œβ€“no-binary” just for experimenting. This worked for me and I’m now able to use the remote agent again.

I’m not deep in the pio codebase and architecture, so it is really only a β€œworks for me” solution.
I’m also not sure of the consequences when it now fetches binary packages.

1 Like

Alas, this didn’t work for me (on a RasPi3 running DietPi in 32-bit mode).

My PATH setting is: PATH="/home/jcw/bin:/home/jcw/.platformio/penv/bin:...

What I notice is that multiple versions of cryptography are being installed, including the newer 36.0 one which is explicitly excluded in another part of the installation process. I’ve re-installed PIO from scratch (using the Super-Quick penv-based approach), and have tried as is and by removing the two --no-binary lines in core.py - no cigar yet.

Update - Hrmph, and now it works - I’ll blame the install failures on a flakey WiFi reception:

$ pio remote agent start
2021-12-10 17:05:37 [info] Name: raspi
2021-12-10 17:05:37 [info] Connecting to PlatformIO Remote Development Cloud
2021-12-10 17:05:38 [info] Successfully connected
2021-12-10 17:05:38 [info] Authenticating
2021-12-10 17:05:39 [info] Successfully authorized

Curiouser and curiouser. Sometimes pio remote agent start downloads stuff all over again and fails, sometimes it works. Here’s a transcript:

$ pio remote agent start
Tool Manager: Installing platformio/contrib-pysite @ ~2.39.0
Unpacking  [####################################]  100%
Tool Manager: contrib-pysite @ 2.39.201020 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-cp39-cp39-linux_armv7l.whl (3.1 MB)
Collecting hyperlink>=17.1.1
  Using cached https://www.piwheels.org/simple/hyperlink/hyperlink-21.0.0-py2.py3-none-any.whl (74 kB)
Collecting constantly>=15.1
  Using cached https://www.piwheels.org/simple/constantly/constantly-15.1.0-py2.py3-none-any.whl (7.9 kB)
Collecting attrs>=19.2.0
  Using cached https://www.piwheels.org/simple/attrs/attrs-21.2.0-py2.py3-none-any.whl (53 kB)
Collecting Automat>=0.3.0
  Using cached https://www.piwheels.org/simple/automat/Automat-20.2.0-py2.py3-none-any.whl (37 kB)
Collecting zope.interface>=4.4.2
  Using cached https://www.piwheels.org/simple/zope-interface/zope.interface-5.4.0-cp39-cp39-linux_armv7l.whl (242 kB)
Collecting PyHamcrest!=1.10.0,>=1.9.0
  Using cached https://www.piwheels.org/simple/pyhamcrest/PyHamcrest-2.0.2-py3-none-any.whl (52 kB)
Collecting incremental>=16.10.1
  Using cached https://www.piwheels.org/simple/incremental/incremental-21.3.0-py2.py3-none-any.whl (15 kB)
Collecting six
  Using cached https://www.piwheels.org/simple/six/six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting idna>=2.5
  Using cached https://www.piwheels.org/simple/idna/idna-3.3-py3-none-any.whl (64 kB)
Collecting setuptools
  Using cached https://www.piwheels.org/simple/setuptools/setuptools-59.5.0-py3-none-any.whl (952 kB)
Installing collected packages: six, setuptools, idna, attrs, zope.interface, PyHamcrest, incremental, hyperlink, constantly, Automat, twisted
Successfully installed Automat-20.2.0 PyHamcrest-2.0.2 attrs-21.2.0 constantly-15.1.0 hyperlink-21.0.0 idna-3.3 incremental-21.3.0 setuptools-59.5.0 six-1.16.0 twisted-20.3.0 zope.interface-5.4.0
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting cryptography<35.0.0,>=3.3
  Using cached https://www.piwheels.org/simple/cryptography/cryptography-3.4.8-cp39-cp39-linux_armv7l.whl (2.0 MB)
Collecting cffi>=1.12
  Using cached https://www.piwheels.org/simple/cffi/cffi-1.15.0-cp39-cp39-linux_armv7l.whl (369 kB)
Collecting pycparser
  Using cached https://www.piwheels.org/simple/pycparser/pycparser-2.21-py2.py3-none-any.whl (119 kB)
Installing collected packages: pycparser, cffi, cryptography
Successfully installed cffi-1.15.0 cryptography-3.4.8 pycparser-2.21
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyopenssl>=16.0.0
  Using cached https://www.piwheels.org/simple/pyopenssl/pyOpenSSL-21.0.0-py2.py3-none-any.whl (55 kB)
Collecting six>=1.5.2
  Using cached https://www.piwheels.org/simple/six/six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting cryptography>=3.3
  Using cached https://www.piwheels.org/simple/cryptography/cryptography-36.0.0-cp39-cp39-linux_armv7l.whl (2.7 MB)
Collecting cffi>=1.12
  Using cached https://www.piwheels.org/simple/cffi/cffi-1.15.0-cp39-cp39-linux_armv7l.whl (369 kB)
Collecting pycparser
  Using cached https://www.piwheels.org/simple/pycparser/pycparser-2.21-py2.py3-none-any.whl (119 kB)
Installing collected packages: pycparser, cffi, six, cryptography, pyopenssl
Successfully installed cffi-1.15.0 cryptography-36.0.0 pycparser-2.21 pyopenssl-21.0.0 six-1.16.0
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/cryptography already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/six-1.16.0.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/six.py already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/cffi-1.15.0.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/cffi already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/_cffi_backend.cpython-39-arm-linux-gnueabihf.so already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/pycparser-2.21.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/pycparser 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 https://www.piwheels.org/simple/service-identity/service_identity-21.1.0-py2.py3-none-any.whl (12 kB)
Collecting pyasn1
  Using cached https://www.piwheels.org/simple/pyasn1/pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Collecting cryptography
  Using cached https://www.piwheels.org/simple/cryptography/cryptography-36.0.0-cp39-cp39-linux_armv7l.whl (2.7 MB)
Collecting attrs>=19.1.0
  Using cached https://www.piwheels.org/simple/attrs/attrs-21.2.0-py2.py3-none-any.whl (53 kB)
Collecting pyasn1-modules
  Using cached https://www.piwheels.org/simple/pyasn1-modules/pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
Collecting six
  Using cached https://www.piwheels.org/simple/six/six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting cffi>=1.12
  Using cached https://www.piwheels.org/simple/cffi/cffi-1.15.0-cp39-cp39-linux_armv7l.whl (369 kB)
Collecting pycparser
  Using cached https://www.piwheels.org/simple/pycparser/pycparser-2.21-py2.py3-none-any.whl (119 kB)
Installing collected packages: pycparser, pyasn1, cffi, six, pyasn1-modules, cryptography, attrs, service-identity
Successfully installed attrs-21.2.0 cffi-1.15.0 cryptography-36.0.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 pycparser-2.21 service-identity-21.1.0 six-1.16.0
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/attrs-21.2.0.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/attr already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/cryptography-36.0.0.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/cryptography already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/six-1.16.0.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/six.py already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/cffi-1.15.0.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/cffi already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/_cffi_backend.cpython-39-arm-linux-gnueabihf.so already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/pycparser-2.21.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/pycparser 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 https://www.piwheels.org/simple/idna/idna-3.3-py3-none-any.whl (64 kB)
Installing collected packages: idna
Successfully installed idna-3.3
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/idna-3.3.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory /home/jcw/.platformio/packages/contrib-pysite/idna already exists. Specify --upgrade to force replacement.
Error: Traceback (most recent call last):
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/platformio/__main__.py", line 129, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/platformio/commands/__init__.py", line 44, in invoke
    return super(PlatformioCLI, self).invoke(ctx)
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/platformio/commands/remote/command.py", line 58, in remote_agent_start
    from platformio.commands.remote.client.agent_service import RemoteAgentService
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/platformio/commands/remote/client/agent_service.py", line 24, in <module>
    from platformio.commands.remote.client.base import RemoteClientBase
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/platformio/commands/remote/client/base.py", line 30, in <module>
    from platformio.commands.remote.factory.ssl import SSLContextFactory
  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/platformio/commands/remote/factory/ssl.py", line 16, in <module>
    from OpenSSL import SSL  # pylint: disable=import-error
  File "/home/jcw/.platformio/packages/contrib-pysite/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/home/jcw/.platformio/packages/contrib-pysite/OpenSSL/crypto.py", line 17, in <module>
    from OpenSSL._util import (
  File "/home/jcw/.platformio/packages/contrib-pysite/OpenSSL/_util.py", line 6, in <module>
    from cryptography.hazmat.bindings.openssl.binding import Binding
  File "/home/jcw/.platformio/packages/contrib-pysite/cryptography/hazmat/bindings/openssl/binding.py", line 170, in <module>
    _verify_package_version(cryptography.__version__)
  File "/home/jcw/.platformio/packages/contrib-pysite/cryptography/hazmat/bindings/openssl/binding.py", line 159, in _verify_package_version
    raise ImportError(
ImportError: The version of cryptography does not match the loaded shared object. This can happen if you have multiple copies of cryptography installed in your Python path. Please try creating a new virtual environment to resolve this issue. Loaded python version: 3.1.1, shared object version: b'3.4.8'

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

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

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

$ pio remote agent start
2021-12-10 17:17:40 [info] Name: raspi
2021-12-10 17:17:40 [info] Connecting to PlatformIO Remote Development Cloud
2021-12-10 17:17:40 [info] Successfully connected

I probably did have WiFi connectivity issues, but I don’t see how this could lead to the above.

It should be fixed with the latest PIO Core. Could you run pio upgrade --dev and restart PIO Remote agent?

Still weird (version 5.2.4b4) - here’s the end of the transcript:

  File "/home/jcw/.platformio/penv/lib/python3.9/site-packages/platformio/commands/remote/factory/ssl.py", line 16, in <module>
    from OpenSSL import SSL  # pylint: disable=import-error
  File "/home/jcw/.platformio/packages/contrib-pysite/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/home/jcw/.platformio/packages/contrib-pysite/OpenSSL/crypto.py", line 17, in <module>
    from OpenSSL._util import (
  File "/home/jcw/.platformio/packages/contrib-pysite/OpenSSL/_util.py", line 6, in <module>
    from cryptography.hazmat.bindings.openssl.binding import Binding
  File "/home/jcw/.platformio/packages/contrib-pysite/cryptography/hazmat/bindings/openssl/binding.py", line 170, in <module>
    _verify_package_version(cryptography.__version__)
  File "/home/jcw/.platformio/packages/contrib-pysite/cryptography/hazmat/bindings/openssl/binding.py", line 159, in _verify_package_version
    raise ImportError(
ImportError: The version of cryptography does not match the loaded shared object. This can happen if you have multiple copies of cryptography installed in your Python path. Please try creating a new virtual environment to resolve this issue. Loaded python version: 3.1.1, shared object version: b'3.3.2'

And then, surprisingly: pio remote agent start … works, repeatedly, and consistently. IOW, the build leads to an error, but the result is a working setup.

I still see cryptography 36.0 getting built twice (and taking quite some time on RasPi). Not sure this is relevant.

Update - here’s some additional info:

$ find .platformio/ -name 'cryptogra*'
.platformio/packages/contrib-pysite/cryptography
.platformio/packages/contrib-pysite/cryptography-36.0.0.dist-info
.platformio/packages/contrib-pysite/service_identity/__pycache__/cryptography.cpython-39.pyc
.platformio/packages/contrib-pysite/service_identity/cryptography.py
.platformio/packages/contrib-pysite/cryptography-3.3.2.dist-info
$

Should be fixed in the latest PIO Core 5.2.4 PlatformIO Core 5.2 πŸš€ - #7 by ivankravets

I’m getting the same behaviour in 5.2.5a1 as before:

File β€œ/home/jcw/.platformio/packages/contrib-pysite/cryptography/hazmat/bindings/openssl/binding.py”, line 159, in _verify_package_version
raise ImportError(
ImportError: The version of cryptography does not match the loaded shared object. This can happen if you have multiple copies of cryptography installed in your Python path. Please try creating a new virtual environment to resolve this issue. Loaded python version: 3.1.1, shared object version: b’3.4.8’

This time around, I can’t find a second instance of cryptography. After a reboot, pio remote agent start works fine.

Some some reason, running pio remote device list on my Mac does the same: fail with an error about the cryptography version, and then the next runs work, properly reporting the remote devices.

I can’t find any 2nd install of cryptography.

Summary: still build errors, but it does work. Confusing.

Update - This often happens, i.e. a download of what to me seems like an older version:

$ pio update
Updating platformio/contrib-pysite            2.39.211215 @ ~2.39.0              [Updating to 2.39.201019]
Tool Manager: Installing platformio/contrib-pysite @ 2.39.201019
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: contrib-pysite @ 2.39.201019 has been installed!
Tool Manager: Removing contrib-pysite @ 2.39.211215
Tool Manager: contrib-pysite @ 2.39.211215 has been removed!

To follow-up: pio update always replaces contrib-pysite with an older version, and after that pio remote agent start always does a complete (slow) rebuild before failing, even though the result (i.e. the next run) works fine.

It looks like these two steps are fighting with each other.

I see this issue, just need to repeat command, no need to reboot. We will work on the fix.

Reopening this topic - I’m suffering from the very same problem, however none of the tips helped. I’m on the most recent version of PIO both on remote host and my local dev machine. Is there any update on this?

Could you provide any output from the pio remote agent start command?

Sure - will take some time however as the whole process runs on a remote RPi with a rather slow 3G connection for downloading the packets (and a slow crypto build process). In principle, it looks very similar (if not the same) as @jcw 's paste from Pio agent fails to install or run - Raspbian buster - #15 by jcw, however the suggestions / insights from this link do not work for me (I’m on the current version, and reboot or repeatedly starting the remote agent does not work - gives me the same output again with the build error after waiting for a long time).

Will generate the output and post it here, hopefully later today!

Okay, I really hate to be that guy, but…it works. Didn’t do anything different to the last several tries, however now I see the exact same behaviour as @jcw with the build failing but the remote agent working (well, uploading doesn’t work yet, but that seems to be a completely different issue).

Sorry for bothering you, and thanks for your time!

Yes, it fails with the first attempt to run the agent but will work in the next cases. This is a known issue. We will work on it.