[SOLVED]Cannot erase flash, ESP32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
dps
Posts: 51
Joined: Mon Oct 28, 2019 9:37 pm

Re: [SOLVED]Cannot erase flash, ESP32

Post by dps » Mon Nov 04, 2019 7:27 am

jimmo wrote:
Sun Nov 03, 2019 11:47 pm
dps wrote:
Sun Nov 03, 2019 6:14 pm
I did however, figure out my troubles with just using esptool in the first place. im a noob at all of this, so i guess thats why. but i wasnt able to just use "esptool.py" at the terminal. come to find out, to be able to do that i needed to install esptool via "pip3" with sudo, not without sudo. it worked like a charm this time.
In general, try to avoid using "sudo pip install" on Linux. The issue is that it can end up conflicting with Python packages installed by your system package manager (e.g. Ubuntu). So for something like esptool, use "apt install esptool".

Alternatively, you can use a Python virtual environment, which lets you make a kind of sandboxed Python installation with its own set of installed packages.

Code: Select all

# Create a directory named venv-esptool
python3 -m venv venv-esptool

# Enter the venv
source venv-esptool/bin/activate

# Now anything you do with pip will be confined to this sandbox. You can install packages without sudo etc.
pip install esptool
esptool --help

# Leave the venv
deactivate
(In future sessions, you just start with the "source" line).
Thank you for your reply. I had followed a tutorial on something that had me setup a virtualenv, but I was confused on how they worked, and how to really use them. I get this idea that there is a directory somewhere for easy one that I create. Is that true? Do you have link to a "noobs" tutorial on these virtualenv?

User avatar
dps
Posts: 51
Joined: Mon Oct 28, 2019 9:37 pm

Re: [SOLVED]Cannot erase flash, ESP32

Post by dps » Mon Nov 04, 2019 7:29 am

rcolistete wrote:
Mon Nov 04, 2019 12:03 am
Or create conda environments (install Anaconda).
What's the difference between the two (virtualenv and conda), and do you have a link to a decent guide for someone who has no experience with them?

User avatar
dps
Posts: 51
Joined: Mon Oct 28, 2019 9:37 pm

Re: [SOLVED]Cannot erase flash, ESP32

Post by dps » Mon Nov 04, 2019 7:31 am

Oh wait, I think I see how the virtualenv works now, it IS a directory. I should have read that a bit more

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: [SOLVED]Cannot erase flash, ESP32

Post by jimmo » Mon Nov 04, 2019 10:39 am

dps wrote:
Mon Nov 04, 2019 7:31 am
Oh wait, I think I see how the virtualenv works now, it IS a directory. I should have read that a bit more
Yeah -- "python3 -m venv my-virtual-env" means "run the venv built-in module, to create a directory named my-virtual-env".

This directory will contain a few things
- scripts to set up / manage the venv
- a place to store installed python libraries

"source" is a bash built-in that runs a script in the scope of the current shell. i.e. it's as if you typed those commands in directly. my-virtual-env/bin/activate is a bash script that replaces your $PATH and some other env vars such that:
- "python" (and "pip") is the version of Python that you used to create the venv
- it changes the library path to use the venv instead
- "deactivate" is available in your path.

(note, you may see tutorials saying ". my-virtual-env/bin/activate" -- "." is an alias for "source"

I don't know much about anaconda / conda, but it's basically a more sophisticated version of virtual environments. my understanding is it extends the idea to much more than just Python libraries -- i.e. there are data packages and things. Haven't really looked into it as virtual environments have served me well (and for everything else there's Docker!


User avatar
dps
Posts: 51
Joined: Mon Oct 28, 2019 9:37 pm

Re: [SOLVED]Cannot erase flash, ESP32

Post by dps » Tue Nov 05, 2019 7:50 am

Thank you guys so much! This is an awesome community!

Post Reply