Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Cannot install it correctly on macOS Big Sur #70

Closed
varosi opened this issue Dec 16, 2020 · 13 comments
Closed

Cannot install it correctly on macOS Big Sur #70

varosi opened this issue Dec 16, 2020 · 13 comments

Comments

@varosi
Copy link

varosi commented Dec 16, 2020

After installing the library via PlatfromIO on Visual Studio Code and when I try to build the project I get:

ModuleNotFoundError: No module named 'asn1crypto':
  File "/Users/home/.platformio/penv/lib/python3.8/site-packages/platformio/builder/main.py", line 170:
    env.SConscript("$BUILD_SCRIPT")
  File "/Users/home/.platformio/packages/tool-scons/scons-local-4.0.1/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)

I have already installed asn1crypto globally, but it's strange that this is a some other environment. My Python is 3.9, not 3.8.
Is it possible this library to auto-install asn1crypto where is needed during installation process in Visual Studio Code?

@varosi
Copy link
Author

varosi commented Dec 16, 2020

The same happen on Windows also.

@maxgerhardt
Copy link
Contributor

maxgerhardt commented Dec 16, 2020

Just open a PIO terminal and do a pip3 install asn1crypto -- PIO is running in it's own isolated penv

@varosi
Copy link
Author

varosi commented Dec 16, 2020

And this is the result:
Requirement already satisfied: asn1crypto in /usr/local/lib/python3.9/site-packages (1.4.0)

This still doesn't help.

@maxgerhardt
Copy link
Contributor

maxgerhardt commented Dec 16, 2020

Requirement already satisfied: asn1crypto in /usr/local/lib/python3.9/site-packages (1.4.0)
File "/Users/home/.platformio/penv/lib/python3.8/site-packages/platformio/builder/main.py", line 170:

You're still using your global 3.9 installation and not the isolated 3.8 installation of PlatformIO.

Try it this way in a normal terminal:

cd /Users/home/.platformio/penv/Scripts
./activate
./pip3 install asn1crypto

@varosi
Copy link
Author

varosi commented Dec 16, 2020

There is no "Scripts" folder there.

@maxgerhardt
Copy link
Contributor

How did you install PlatformIO? Via the CLI first or just with the VSCode plugin?

@varosi
Copy link
Author

varosi commented Dec 16, 2020

VSCode plugin

@varosi
Copy link
Author

varosi commented Dec 16, 2020

There is /Users/home/.platformio/penv/ but without "Scripts". In "bin" folder there is "activate", but it's not executable.

@maxgerhardt
Copy link
Contributor

Is a pip3 executable file in this folder with which you can do ./pip3 install asn1crypto?

@maxgerhardt
Copy link
Contributor

maxgerhardt commented Dec 16, 2020

Okay please post the output of pio system info when executed in a PIO terminal.

Otherwise you can try to replace this line

from asn1crypto.x509 import Certificate

with

try:
    from asn1crypto.x509 import Certificate
except ImportError:
    env.Execute(
        env.VerboseAction(
            '$PYTHONEXE -m pip install "asn1crypto" ',
            "ASN1 crypto import failed, installing.",
        )
    )

and try building twice (first to catch error + install, second to actually execute)

@varosi
Copy link
Author

varosi commented Dec 16, 2020

It worked! At least continued with the compilation.

Thanks a lot!
It could be easier I guess if the installation process of the library include that dependency automatically.

@maxgerhardt
Copy link
Contributor

maxgerhardt commented Dec 16, 2020

I've proposed that in PR #71 :)

However, this should also be equivalent of executing pio system info, copying the value of the Python Executable entry and then appending -m pip install asn1crypto to it and executing it in a shell.

@maakbaas
Copy link
Owner

@maxgerhardt Thanks for supporting, and for the pull request. Indeed automatic installation of this dependency (and others) was already on my list for some time. I appreciate it!

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

No branches or pull requests

3 participants