Replies: 7 comments 5 replies
-
You can build the .mpy bytecode file using the mpy-cross module, like this:
where $SRC_FILE is the name of the original .py file. You can also do this automatically as part of a GitHub Action. See this discussion topic for details. |
Beta Was this translation helpful? Give feedback.
-
very kind to answer me but I have a question as I am new in this area I
download pypi.org and install it as a plugging from thonny and compile it I
found it as mpy - cross-v6 but this one with this same pip shows the same
errors it could be more detailed is that I am very new in this area
El mar, 19 de dic de 2023, 7:47 a. m., Dave ***@***.***>
escribió:
… You can build the .mpy bytecode file using the mpy-cross module, like this:
pip3 install mpy-cross
python3 -m mpy_cross $SRC_FILE
where *$SRC_FILE* is the name of the original .py file.
You can also do this automatically as part of a GitHub Action. See this
discussion topic <#13152>
for details.
—
Reply to this email directly, view it on GitHub
<#13228 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEW3HC4LRPGAIBMRZNZABKTYKGEEVAVCNFSM6AAAAABA2U3O7GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TQOJXGA4DO>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
WITH WHICH IDE COMPILER YOUR ESP32 PROGRAMS
THEN I JUST TYPE py.exe -m mpy_cross .\thimble.py IN CMD AND IT ALREADY
LOADS?
El mar, 19 dic 2023 a las 10:42, Dave ***@***.***>) escribió:
… I have not tried using it from Thonny, so I don't know if it's possible.
However, from Windows command-line, this works:
py.exe -m pip install mpy-cross
py.exe -m mpy_cross .\thimble.py
I'm using Python 3.12 installed from the MSI package at
https://www.python.org/downloads/
—
Reply to this email directly, view it on GitHub
<#13228 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEW3HC3L2E3EUZSQZM5S3BDYKGYVZAVCNFSM6AAAAABA2U3O7GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TQOJZGE2TC>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
This is what appears to me, I installed one package but the other did not
'"C:\Espressif\idf_cmd_init.bat"' is not recognized as an internal or
external command,
operable program or batch file.
C:\Espressif\frameworks\esp-idf-v5.1.2>py.exe -m pip install mpy-cross
Collecting mpy-cross
Obtaining dependency information for mpy-cross from
https://files.pythonhosted.org/packages/58/e1/c67a584bf3c0430eb4ac0183ef39edb6ff212bbcb5a0d01827fe51c61348/mpy_cross-1.21.0-py2.py3-none-win_amd64.whl.metadata
Downloading mpy_cross-1.21.0-py2.py3-none-win_amd64.whl.metadata (2.8 kB)
Downloading mpy_cross-1.21.0-py2.py3-none-win_amd64.whl (144 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 144.4/144.4 kB 854.4 kB/s eta
0:00:00
Installing collected packages: mpy-cross
Successfully installed mpy-cross-1.21.0
[notice] A new release of pip is available: 23.2.1 -> 23.3.2
[notice] To update, run: python.exe -m pip install --upgrade pip
C:\Espressif\frameworks\esp-idf-v5.1.2>
C:\Espressif\frameworks\esp-idf-v5.1.2>py.exe -m mpy_cross .\thimble.py
OSError: (2, "can't open ./thimble.py")
C:\Espressif\frameworks\esp-idf-v5.1.2>
C:\Espressif\frameworks\esp-idf-v5.1.2>
El mar, 19 dic 2023 a las 10:55, Jhordan Zapata ***@***.***>)
escribió:
… WITH WHICH IDE COMPILER YOUR ESP32 PROGRAMS
THEN I JUST TYPE py.exe -m mpy_cross .\thimble.py IN CMD AND IT ALREADY
LOADS?
El mar, 19 dic 2023 a las 10:42, Dave ***@***.***>)
escribió:
> I have not tried using it from Thonny, so I don't know if it's possible.
> However, from Windows command-line, this works:
>
> py.exe -m pip install mpy-cross
> py.exe -m mpy_cross .\thimble.py
>
> I'm using Python 3.12 installed from the MSI package at
> https://www.python.org/downloads/
>
> —
> Reply to this email directly, view it on GitHub
> <#13228 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/BEW3HC3L2E3EUZSQZM5S3BDYKGYVZAVCNFSM6AAAAABA2U3O7GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TQOJZGE2TC>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***
> com>
>
|
Beta Was this translation helpful? Give feedback.
-
Suddenly you have a video on how to do it, I don't understand much
El mar, 19 dic 2023 a las 11:12, Dave ***@***.***>) escribió:
… Sorry, the .\thimble.py was a copy-paste mistake in my example. It should
be whatever the name of your MicroPython file is.
I'm using mpy_cross to pre-compile a module I have written into byte code.
The resulting .mpy file goes in the /lib directory on my microcontroller.
For the example of *thimble.py*, when I do from thimble import Thimble in
my *main.py*, it will load the thimble.mpy file.
This is not required, but does speed up module loading. It is also more
space efficient. The resulting .mpy is less than 1/4 the size of the
original. You don't need to do this for most MicroPython programs you write.
—
Reply to this email directly, view it on GitHub
<#13228 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEW3HC6NMKSTUZ6Z6EORA53YKG4GDAVCNFSM6AAAAABA2U3O7GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TQOJZGUYTS>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
esto es lo que me aparece en instalar en cmd el pluggin
py.exe -m mpy_cross sourcefile.py
se puede solamente con el primero
py.exe -m pip install mpy-cross
C:\Users\J. Zapata>py.exe -m mpy_cross sourcefile.py
OSError: (2, "can't open sourcefile.py")
What programs do you run the programs with?
El mar, 19 dic 2023 a las 11:22, Dave ***@***.***>) escribió:
… I'm not aware of any videos. I got my information from searching here and
there. I don't recall the sources. It basically comes down to this:
Windows
py.exe -m pip install mpy-cross
py.exe -m mpy_cross sourcefile.py
Linux
pip3 install mpy-cross
python3 -m mpy_cross sourcefile.py
In the end, you get sourcefile.mpy
—
Reply to this email directly, view it on GitHub
<#13228 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEW3HC5L2SUXNC3EGKE3DKTYKG5KTAVCNFSM6AAAAABA2U3O7GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TQOJZGYYTG>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
thank you for sharing your generous time with me that sourcefile.py does
not install in cmd and I change the name in thonny as it says sourcefile.py
[image: image.png]
El mar, 19 dic 2023 a las 11:47, Dave ***@***.***>) escribió:
… Substitute the name of your MicroPython file in place of sourcefile.py
—
Reply to this email directly, view it on GitHub
<#13228 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEW3HC6NUE2DF4RB322AEJ3YKHAKLAVCNFSM6AAAAABA2U3O7GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TQOJZHEYDI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a code for an antivirus that when it detects a virus hash but an error appears then I have to convert it to mpy because this is pyton code
This code
import hashlib
def calcular_hash(archivo):
"""Calcula el hash SHA256 de un archivo."""
sha256_hash = hashlib.sha256()
with open(archivo, "rb") as f:
# Leer y actualizar el hash en bloques de 4K
for byte_block in iter(lambda: f.read(4096), b""):
sha256_hash.update(byte_block)
return sha256_hash.hexdigest()
def verificar_virus(hash_archivo, db_virus):
"""Verifica si el hash del archivo está en la base de datos de virus."""
return hash_archivo in db_virus
Lista de hashes de virus conocidos (ejemplo)
db_virus_conocidos = [
"hash_virus_1",
"hash_virus_2",
"hash_virus_3",
]
Asignar ruta
ruta = "myfile.txt"
Calcula el hash del archivo
hash_del_archivo = calcular_hash(ruta)
print(f'El hash del archivo {ruta} es {hash_del_archivo}')
Verificar si el archivo es un virus conocido
es_virus = verificar_virus(hash_del_archivo, db_virus_conocidos)
if es_virus:
print("Alerta: El archivo es un virus conocido.")
else:
print("El archivo no coincide con ningún virus conocido en la base de datos.")
The errors is
este hash_del_archivo = calcular_hash(ruta) y with open(archivo, "rb") as f:
It.says
File "", line 27, in
File "", line 6, in calcular_hash
Beta Was this translation helpful? Give feedback.
All reactions