'Import issues in Visual Studio Code
I am trying to execute this code in Visual Studio Code, the code works, my problem is related to the import of numpy; the other imports are working.
import codecs
from operator import le
import string
from struct import unpack
import paho.mqtt.client as mqtt
import struct
import numpy as np
def on_connect1(client1, userdata1, flags1, rc1):
client1.subscribe("MYTOPIC")
def on_message1(client1, userdata1, msg1):
#print(msg1.topic+" "+ "TERMORESISTENZA: "+str(msg1.payload))
Byte_Order = '<' # little-endian
Format_Characters = 'f' # float (4 bytes)
data_format = Byte_Order + Format_Characters
r = np.array(list(struct.iter_unpack(data_format, msg1.payload)), dtype=float)
print(r)
When I run the code it returns me this error: ModuleNotFoundError: No module named 'numpy'
Any suggestions?
Solution 1:[1]
I used the Windows Command Prompt to install numpy with the command:
pip install numpy
and solved the problem
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Max Scoch |