在Ubuntu上的Arduino IDE上为NodeMCU编译时出错

时间:2019-06-27 19:08:01

标签: linux ubuntu arduino

我一直在尝试使用NodeMCU将一段代码与Blynk应用程序链接,并且正在Ubuntu的Arduino IDE上编译代码。以下是我的代码:

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "myAuthToken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "myWifi";
char pass[] = "myPassword";
BlynkTimer timer;
void setup()
{
  // Debug console
  Serial.begin(9600);
  timer.setInterval(1000L, function);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
  Blynk.run();
  timer.run();
}
void function()
{
  int ldrValue=analogRead(A0);
  Blynk.virtualWrite(V1, ldrValue);
}

每当我尝试编译它时,它向我显示一个错误。以下是错误消息:

Arduino: 1.8.5 (Linux), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

fork/exec /home/enlightened/snap/arduino-mhall119/5/.arduino15/packages/esp8266/tools/python/3.7.2-post1/python: no such file or directory
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

2 个答案:

答案 0 :(得分:3)

您需要安装Python,或者在Arduino IDE中修复(重新链接)指向Python二进制文件的文件。

打开一个终端( ctrl + alt + T ),在提示符下键入python,按 enter

~$ python

如果终端建议安装Python,则这样做可能会解决问题:

~$ sudo apt-get install python

否则,如果您看到此内容:

~$ python
Python 2.7.16 (default, Apr  6 2019, 01:42:57) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

这意味着已安装Python,但您需要修复此文件中的符号链接:

/home/enlightened/snap/arduino-mhall119/5/.arduino15/packages/esp8266/tools/python/3.7.2-post1/python

指向已安装的Python二进制文件,如下所示:

~$ ln -s /usr/bin/python /home/enlightened/snap/arduino-mhall119/5/.arduino15/packages/esp8266/tools/python/3.7.2-post1/python

答案 1 :(得分:0)

这是arduino-mhall119捕捉的问题。它已损坏且已弃用,您应改为安装arduino卡扣。它支持Python 3。

snap install arduino

如果您尚未这样做,请执行以下操作:您还应该将用户添加到dailout组中,以便它可以访问USB串行设备。

sudo usermod -a -G dialout $USER

此后,重新启动设备并运行“ Arduino IDE”。

详细信息

快照在沙箱中运行应用程序,因此它无法访问您设备的Python。 arduino快照通过在该沙箱中捆绑Python 内部来解决此问题。

未找到模块。

如果需要尚未在快照中安装的其他Python模块,则可以通过运行arduino.pip install <packagename>自行安装它们。这将使用pip将软件包安装在沙箱中。