ESP8266_AT_LoBo icon indicating copy to clipboard operation
ESP8266_AT_LoBo copied to clipboard

Python 2 seems to be required

Open jcrossley3 opened this issue 3 years ago • 6 comments

I'm on Fedora 31, which has sort of "retired" python 2 in favor of 3. I had to make the following changes in order for ./build.sh to get past some "missing parentheses" errors:

modified   Makefile
@@ -281,7 +281,7 @@ endif
 	@echo "!!!"
 	
 ifeq ($(app), 0)
-	@python ../tools/gen_appbin.py $< 0 $(mode) $(freqdiv) $(size_map) $(app)
+	@python2 ../tools/gen_appbin.py $< 0 $(mode) $(freqdiv) $(size_map) $(app)
 	@mv eagle.app.flash.bin ../bin/eagle.flash.bin
 	@mv eagle.app.v6.irom0text.bin ../bin/eagle.irom0text.bin
 	@rm eagle.app.v6.*
@@ -291,10 +291,10 @@ ifeq ($(app), 0)
 	@echo "eagle.irom0text.bin---->0x10000"
 else
     ifneq ($(boot), new)
-		@python ../tools/gen_appbin.py $< 1 $(mode) $(freqdiv) $(size_map) $(app)
+		@python2 ../tools/gen_appbin.py $< 1 $(mode) $(freqdiv) $(size_map) $(app)
 		@echo "Support boot_v1.1 and +"
     else
-		@python ../tools/gen_appbin.py $< 2 $(mode) $(freqdiv) $(size_map) $(app)
+		@python2 ../tools/gen_appbin.py $< 2 $(mode) $(freqdiv) $(size_map) $(app)
 
     	ifeq ($(size_map), 6)
 		@echo "Support boot_v1.4 and +"

If acceptable, I'm happy to submit a PR. Other than that tiny issue, everything else worked like a charm, thanks!

jcrossley3 avatar Sep 18 '20 12:09 jcrossley3

what i had done:

  • install 2to3 (pip install 2to3)
  • convert from python2 to python3 (2to3 -w -n tools/gen_appbin.py)
  • replace any tab found with eigth spaces (with sed or vim for example)
  • edit tools/gen_appbin.py ... --- line 62, before --- fp.write(data) --- lines 62-65, after --- if isinstance(data, str): fp.write(bytes(data, 'utf-8')) else: fp.write(data) --- done ---

@loboris PLEASE COMMIT THIS FILE CONVERTED FOR NEXT RELEASE

atesin avatar Sep 22 '20 03:09 atesin

An easy workaround: in the folder where you cloned the repo set up a virtual environment with python2. To do so, find where your python2 is: which python2, on my machine (Kubuntu 20.04) it was /usr/bin/python2.

Create a virtual environment with

virtualenv -p /usr/bin/python2 venv

then activate it with

source venv/bin/activate

Now if you just type python you'll see that it's 2.7.x and not 3.x.x. And ./build.sh works like a charm :)

nebelgrau77 avatar Oct 10 '20 16:10 nebelgrau77

virtualenv is good alternative, should be mentioned in readme.md

uzi18 avatar Oct 10 '20 17:10 uzi18

I just opened a PR with this explanatory note added at the end, and also another fix for flashing problems.

nebelgrau77 avatar Oct 11 '20 06:10 nebelgrau77

... or even better,... should open a PR with the updated gen_appbin.py file for python3

atesin avatar Apr 04 '22 05:04 atesin