0

Confusing info
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Confusing info

by 7b_w on Thu Dec 01, 2016 6:20 pm

I have been attempting to setup this MicroPython for a while now and going through the tutorials has me confused on which way i need
to proceed.
I have an ESP-01 board that i have setup Reset and program keys with a v. regulator and level shifter between the USB FTDI chip and
the ESP-01 board. I have been successful in loading programs using the Audruino IDE to this ESP-01 but the MicroPython has me
intrigued and I would like to use that but the tutorials here have me confused.
I have installed Python 3.5 and have downloaded the file that contains the esptool.py but do I run that from the IDLE(Python 3.5) and is
this how you install firmware on the ESP-01? Does the esptool communicate via the USB port to talk to the ESP-01?
I am missing something here between the tutorials on this site in regards to this and could use some helpful hints. I am using Windows
and the IDLE is opening up and I can load a module but when i try to run esptool I get an error about missing parenthesis on a print
statement line.
Not sure where i am going wrong and could use some guidance.
Thanks

7b_w
 
Posts: 13
Joined: Sun Jan 17, 2016 10:06 pm

Re: Confusing info

by 7b_w on Thu Dec 01, 2016 7:29 pm

More info:
I open Python 3.5 shell and greeted with:
>>>
So far so good(?)
Then in the Python shell I type:
pip2 install esptool

And I am greeted with:
install is highlighted and then this:
SyntaxError: invalid syntax

It seems the problem is trying to get esptool to install but keeps ending up with an error
and I have no clue as to why and i have tried many work arounds as listed but they fail too
so where am I going wrong?
Thanks.

7b_w
 
Posts: 13
Joined: Sun Jan 17, 2016 10:06 pm

Re: Confusing info

by superjudge on Fri Dec 02, 2016 2:24 am

Hi,

I know nothing about the ESP-01 board, so I cannot help you with specifics there, but I may be able to get you a little further on the way! A quick Googling also gave this link, which warns that recent versions of MicroPython for ESP8266 requires more than 512KB of flash, which, apparently, some versions of the ESP-01 does not have. Be sure to check this before proceeding. Also, I am not sure whether the Adafruit port of MicroPython is the right thing to go for, as a cannot see that Adafruit carries the ESO-01. I think the Adafruit port is mostly targeting their own boards, so you may be better off going to the regular MicroPython forum, http://forum.micropython.org/index.php.

The "pip2" command is actually a separate program (written in Python) for finding and installing additional Python packages. Thus, you should not run it from within Python, but rather from the command line in your shell.

What OS are you running? I am mostly familiar with Linux (pip is available also on Windows, but the procedure of installing might be a bit different), where in e.g. Ubuntu, pip is an additional package that you may need to install before the command is available. For "pip2" (i.e. pip for Python 2) you would do something like:

$ sudo apt install python-pip

And for "pip3" (i.e. pip for Python 3) you would do something like:

$ sudo apt install python3-pip

After having installed a version of pip, you should be able to run (from the command line) something like:

$ pip install esptool

As I am not familiar with the ESP-01 and esptool itself, I cannot say more, but I assume installing esptool per above would give you access to an additional command line tool called "esptool", which presumably you can use to flash the ESP-01.


Cheers,

/johan

superjudge
 
Posts: 14
Joined: Sat Nov 26, 2016 12:02 pm

Re: Confusing info

by 7b_w on Fri Dec 02, 2016 11:02 am

Thanks for the reply johan.
I am using Win8.1 and when I start IDLE Python 3.5 I believe I am then in a command shell since I do see this prompt: >>>
When Python 3.5 shell is running I can look for keywords using the help() command and in looking over the list I don't see
the keyword "install" and this has me confused thinking something is still missing.
The ESP-01 is more like Adafruits Huzzah board but I need to see a schematic to verify this but ok on headsup with amount
flash on the 01. I think there is a program that can tell me that by checking the chip on the 01.
I will try looking at the MicroPython .org forum and see if I can get a better understanding on how to load the binary.

7b_w
 
Posts: 13
Joined: Sun Jan 17, 2016 10:06 pm

Re: Confusing info

by superjudge on Fri Dec 02, 2016 2:38 pm

I have little experience using Python under Windows, but as far as I understand, pip actually ships already with Python 3 >= 3.4, and Python 2 >=2.7.9. It looks like you are running Python 3.5, so you should already have pip installed together with Python. However, you need to try to run pip *outside* the Python interpreter. IDLE, which you mention, is essentially just a simple tool running the Python interpreter, so when you see the ">>>" prompt, and run the "help()" command, you are doing so WITHIN the Python interpret.

What you need to do is start a regular Windows command line, I guess that would be either cmd or PowerShell (note that I am VERY poor at Windows, so the names here may be wrong), and try to run pip as a regular "program" from that shell. This means that pip needs to be in your PATH, and I am unsure if this will be setup automatically for you by the Windows Python installer. Otherwise you will need to try to find the equivalent of a "bin" directory under your Python installation path (presumably something like C:\Python35 or similar) and see if you can find pip there.

Hope this helps!


Cheers,

/johan

superjudge
 
Posts: 14
Joined: Sat Nov 26, 2016 12:02 pm

Re: Confusing info

by 7b_w on Fri Dec 02, 2016 6:24 pm

This time I am getting closer and what you said about running PIP outside the Python shell was finally starting to make sense.
I didn't like where the Python package was installed so used the custom setting to place it in a location that wasn't so hard to get to.
So using the windows command window I entered "pip install esptool" and this time things started looking good but ran into
a PIP upgrade issue which I went back and installed the upgrade.
Now I get this when I run the short script "pip install esptool":

C:\Users\Ham_Man\Python>pip install esptool
Collecting esptool
Using cached esptool-1.2.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Ham_Man\AppData\Local\Temp\pip-build-ytk8mgcb\esptool\setup
.py", line 9, in <module>
raise RuntimeError("esptool.py only supports Python 2.x")
RuntimeError: esptool.py only supports Python 2.x

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Ham_Man\
AppData\Local\Temp\pip-build-ytk8mgcb\esptool\

C:\Users\Ham_Man\Python>

So progress but an error I am not familiar with other than looks like I may need a newer release of esptool.

7b_w
 
Posts: 13
Joined: Sun Jan 17, 2016 10:06 pm

Re: Confusing info

by superjudge on Sat Dec 03, 2016 3:45 am

Aha, it looks like esptool does not work under Python 3.

Short digression: There are two major versions of Python out in the wild, Python 2 and Python 3. The two versions are very similar, and much of Python 3 has actually been ported back to Python 2, but there are a few incompatible differences between them. Python 3 was made to clean up some inconsistencies in Python 2, but as Python 2 was so widely used, the two versions have existed side by side for a number of years. More and more packages are being ported to Python 3, but many packages are still lagging behind. I guess esptools is one of them.

What you should do is go download and install Python 2 on your machine. I believe it is possible to have both Python 2 and Python 3 installed at the same time on your windows box. However, you may need to be careful with PATH. On Unix-like operating system, the two binaries are usually named "python" (for version 2) and "python3" (for verison 3), but I don't know what the principle is on Windows. I would GUESS that the same principle is used there, but I am not sure.

If you install Python 2 as well, you will likely get another, separate installation directory (e.g. c:\Python2.7.12), a separate IDLE, etc. So if you install Python 2 and then go through the same steps you already did for esptool, you may have better luck!

As a side note, MicroPython is based on Python 3.


Cheers,

/johan

superjudge
 
Posts: 14
Joined: Sat Nov 26, 2016 12:02 pm

Re: Confusing info

by 7b_w on Sat Dec 03, 2016 12:09 pm

I guess this is where some more confusion sits. In looking at the site https://pypi.python.org/pypi/esptool they say to use
pip2 if your using Python 3 but that yields the same error as just plain pip. I have even tried pip3 and same results/error
shows up during the installation of esptool.
I usually don't like to have 2 instances of programs, in this case Python 2 and 3 thinking things might get really messed up
in the install process. I will uninstall Python 3 and install Python 2 and give this esptool another try.
Thanks for all your help so far Johan I will keep you posted.

7b_w
 
Posts: 13
Joined: Sun Jan 17, 2016 10:06 pm

Re: Confusing info

by superjudge on Sat Dec 03, 2016 12:50 pm

Ah, yes, reading the page you refer to, I can see how the confusion can come about. What they are actually saying (under the "Installation" heading), is that esptool indeed REQUIRES Python 2. They continue to say that if your DEFAULT installation of "pip" is actually "pip3", which is pip for Python 3 (implying that you have both Python 2 and Python 3 installed), you need to EXPLICITLY use "pip2", to make sure that you are installing esptool using Python 2.

I can see how this is confusing of you are not used to Python. It does indeed look messy, however, I must stress that Python is actually quite well packaged and managed. The slight mess with Python 2 and Python 3 is unfortunate, but in general, once you being understanding the differences and how the different tools go together, it is usually quite easy to manage having both versions installed at the same time.

But if you are ok living without Python 3 for now, uninstalling it, and installing Python 2 instead will no doubt give you a slightly cleaner environment, and less risk of confusion!

Good luck, and feel free to ask again, if you run into trouble!


Cheers,

/johan

superjudge
 
Posts: 14
Joined: Sat Nov 26, 2016 12:02 pm

Re: Confusing info

by 7b_w on Sun Dec 04, 2016 6:34 pm

So I loaded Python2.X and after setting the path (oops forgot first time) I was successful in loading
the ESPTOOL and then erased the flash on the ESP-01 plus loaded the micropython firmware back
on to the ESP-01. I had PuTTY all set up so used that to talk to the ESP-01 and it worked perfectly!
So from the start if i had loaded 2.X first I would have never run into all this confusion.
All I was trying to do was run the latest and greatest which turns out NOT the way to go.
I think they should add something to this Adafruit tutorial in loading firmware to load and
run Python2.7.X on their PC with what ever op system they have on it to install ESPtool because
Python3.X doesn't work. So now I have Python3.5.X installed too but not sure when I will need to run/use
that or if there will be problems running it.
I now have some ESP-12 boards to use so need to test one of those soon and start learning Micropython!
Johan thanks so much for your help, your thoughts on the issue i was having with all of this helped me
get through this tutorial.
So now the question is what do i use to load and run programs on the ESP8266-01 or 12? WebREPL or AMPY?
Bruce :-)

7b_w
 
Posts: 13
Joined: Sun Jan 17, 2016 10:06 pm

Re: Confusing info

by 7b_w on Mon Dec 05, 2016 11:32 am

After posting that last reply I started looking through the tutorials again and see that WebREPL is for linking to the ESP boards
via WiFi which at some point I will but looks like Ampy is the way to go and have down loaded and installed it already but haven't run it yet.

7b_w
 
Posts: 13
Joined: Sun Jan 17, 2016 10:06 pm

Please be positive and constructive with your questions and comments.