Installation of esptool

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
andymouse
Posts: 12
Joined: Sat Apr 06, 2019 7:05 pm

Installation of esptool

Post by andymouse » Sat Apr 06, 2019 7:21 pm

Hi
Unfortunately I have fallen at the first hurdle !
I am using a windows 10 machine, and have installed Python 2.7 and am greeted with a window detailing version number,
at the prompt I type "pip install esptool" and I receive "File "<STdin>",line1 syntax error: invalid syntax

I have watched a few tutorials and tried different versions of python and different lines including "pip2" and "sudo" but cannot see what I am doing wrong. Python seems to be ok as no errors if I type something like "2*8" I get 16, I must be missing something silly but dont no what.
Please help.
Andy

cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Re: Installation of esptool

Post by cefn » Sun Apr 07, 2019 7:13 am

Well done for getting this far from a standing start! The problem you're facing is you are running a pip command INSIDE the python shell. 'pip' is a command, like 'python' which you should type directly into the Windows terminal. If you are in the python shell, press CTRL+C then type the python instruction exit() and press enter to leave the shell before running a pip command. If you need to launch a Windows terminal from scratch go to start, run and type CMD.exe. Your pip command should work there.

andymouse
Posts: 12
Joined: Sat Apr 06, 2019 7:05 pm

Re: Installation of esptool

Post by andymouse » Sun Apr 07, 2019 7:10 pm

Hi
I am so close I can taste it !!
I have finally after a few hours, and a lot of learning, got to the point where I have "erased" my lolin d1 mini and copied a ".bin" file to it both procedures completed with no errors. I have a better understanding of "esptool" now. I had to change the port from," port /dev/ttyUSB0" to com8 and I set the baud rate to 115200 and watched as the files where copied. I now open "PuTTY" and select com8 and yeah! the Repl appears, but (sad bit) when I type print "hello world" I get:-

>>> Print "hello world"
Traceback (most recent call last):
File "<stdin>", line 1
Syntax Error: invalid syntax
>>>

however if I type print ("hello world") I get :-
>>>
>>> print ("hello world")
hello world
>>>
also if I type 2*8 I get
>>> 2*8
16
>>>
also typing help() gives me the correct page. As I said so close, and all I want to do is learn Micropython!...I will show you what happens if I hit reset on my esp8266, actualy its just "hung up" will now have to restart PuTTY. also if I do a "soft reboot" I get;-
PYB: soft reboot
OSError: [Errno 2] ENOENT
MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
Type "help()" for more information.
>>>
Here's another error message:-
>>>
>>> import machine
>>> from machine import pin
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name pin
>>>
Have you any thoughts or can you point me on to the next step, sorry if the format is wrong and I am not much use from the "command line" but trying my best
Andy

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Installation of esptool

Post by Roberthh » Sun Apr 07, 2019 7:40 pm

Congratulations, you arrived. Now you have to learn the specifics of this Python variant.
First of all, it is more or less python 3.4. with some python 3.5 extensions. So you have to write:
print("Hello World")

Second: The error message:

Code: Select all

OSError: [Errno 2] ENOENT
MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
When booting, Micropython tries to execute boot.py and main.py in that order. On an fresh installed device, main.py does nto exist, and that causes the error message.
To get rid of the error message, you can create main.py skeleton with:

Code: Select all

f = open("main.py", "w")
f.write("# Put your code here\n")
f.close()
Third: Python is case sensitive, and the module you look for is called Pin. So use.;
from machine import Pin

andymouse
Posts: 12
Joined: Sat Apr 06, 2019 7:05 pm

Re: Installation of esptool

Post by andymouse » Sun Apr 07, 2019 10:31 pm

Hi
Thanks !! that cleared that up and all does indeed appear to be fine, now I'm gonna have to hit the books! I now need to get into a Python mind set. I have one last request, I've just had a quick play and attempted to switch an Led on and off and I thought I had it correct but nothing on my Lolin/Wemos D1 Mini changed state and also Repl didn't moan at me so I dont even no if my board is ok or my thinking is wrong, are you familiar with this board? would you show me how to toggle an LED ? does it need to be inside "main.py"? Once again thank you, your a star!

Andy

ThomasChr
Posts: 121
Joined: Sat Nov 25, 2017 7:50 am

Re: Installation of esptool

Post by ThomasChr » Mon Apr 08, 2019 5:01 am

You can toggle a led on the REPL.
Use a while loop with time.sleep() for maybe half a second or so. I haven‘t got the specific code in mind but if you really fail just say so and I look it up and test it for you!

Thomas
Last edited by ThomasChr on Wed Apr 10, 2019 1:42 pm, edited 1 time in total.

andymouse
Posts: 12
Joined: Sat Apr 06, 2019 7:05 pm

Re: Installation of esptool

Post by andymouse » Mon Apr 08, 2019 9:16 am

thanks, but all is well just getting used to It, the problem I had was a dodgy breadboard so my journey has begun thanks to all!

Andy

Jadno
Posts: 5
Joined: Mon Apr 08, 2019 2:05 pm

Re: Installation of esptool

Post by Jadno » Wed Apr 10, 2019 12:35 pm

Hello! Is your question resolved? You do not explain to me why pip did not work? I would love to discuss this because I have the same problem. I tried to сompare and synchronize SQL Server database schemas yesterday and I got a bug. Still, this now to solve(
Last edited by Jadno on Thu Apr 11, 2019 2:23 pm, edited 1 time in total.

andymouse
Posts: 12
Joined: Sat Apr 06, 2019 7:05 pm

Re: Installation of esptool

Post by andymouse » Wed Apr 10, 2019 1:59 pm

Hi
"pip" did not work because I used a version of Python that did not contain the correct files. I then installed the latest Python and my troubles went away. If you install the latest Python follow the instructions carefully because you will be asked to check (Tick) a box that sets the proper "path" for the install, you MUST check this box! After that I found the "pip" command worked as described in the various tutorials. The other error messages that I had were fixed by following the instructions above this post which basically put something in the Micropython file "Main.py"
Hope this helps and you can move on

Andy

Jadno
Posts: 5
Joined: Mon Apr 08, 2019 2:05 pm

Re: Installation of esptool

Post by Jadno » Thu Apr 11, 2019 2:23 pm

Thank you very much! I understood it would help! This was the case for me. I also had VMDK problems. I knew that some common reasons which can cause corruption in the Virtual machine disk file – Virus Infection, Dirty shutdown or abruptly system shutdown and one of the main reasons of this error is included human mistakes such as accidental deletion or removal of the important files, cleaning the system registry, improper disk management issues or forcefully termination etc.
I followed the steps to repair VMDK file data manually and it didn't help but the restoration program did help, everything is fine now.

Post Reply