Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2 seems to be required #8

Open
jcrossley3 opened this issue Sep 18, 2020 · 6 comments
Open

Python 2 seems to be required #8

jcrossley3 opened this issue Sep 18, 2020 · 6 comments

Comments

@jcrossley3
Copy link

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!

@atesin
Copy link

atesin commented Sep 22, 2020

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

@nebelgrau77
Copy link

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 :)

@uzi18
Copy link

uzi18 commented Oct 10, 2020

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

@nebelgrau77
Copy link

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

@atesin
Copy link

atesin commented Apr 4, 2022

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

@carl1961
Copy link

carl1961 commented Jan 9, 2024

On way I got this working is install python 2 and switch to python 2
Each number is command typed (copied) to terminal

  1. sudo apt install python2

  2. python2 -V
    Python 2.7.18

  3. ls /usr/bin/python*
    /usr/bin/python2 /usr/bin/python2.7 /usr/bin/python3 /usr/bin/python3.10

  4. sudo update-alternatives --list python
    update-alternatives: error: no alternatives for python

  5. sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
    update-alternatives: using /usr/bin/python2 to provide /usr/bin/python (python) in auto mode

  6. sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
    update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode

  7. sudo update-alternatives --config python
    There are 2 choices for the alternative python (providing /usr/bin/python).

Selection Path Priority Status

  • 0 /usr/bin/python3 2 auto mode
    1 /usr/bin/python2 1 manual mode
    2 /usr/bin/python3 2 manual mode

Press to keep the current choice[*], or type selection number:

  1. 1
    update-alternatives: using /usr/bin/python2 to provide /usr/bin/python (python) in manual mode

python --version

Python 2.7.18

carl@DESKTOP-9JE80P5:~/ESP8266_AT_LoBo/at_lobo$ ./build.sh

=====================================
Building ESP8266/ESP8285 AT firmwares

Building firmware for 1MB Flash (ESP8285, DOUT spi mode)
File size = 435332
esp8285_AT_1_2.bin OK
esp8285_AT_2_2.bin OK

Building firmware for 512KB Flash, Flash map: 2 (512 no OTA)
File size = 423140
esp8266_AT_1_0.bin OK

Building firmware for 1MB Flash, Flash map: 2 (512+512)
File size = 435332
esp8266_AT_1_2.bin OK
esp8266_AT_2_2.bin OK

Building firmware for 2MB Flash, Flash map: 3 (512+512)
File size = 435396
esp8266_AT_1_3.bin OK
esp8266_AT_2_3.bin OK

Building firmware for 4MB Flash, Flash map: 4 (512+512)
File size = 435396
esp8266_AT_1_4.bin OK
esp8266_AT_2_4.bin OK

Building firmware for 2MB Flash, Flash map: 5 (1024+1024)
File size = 435396
esp8266_AT_1_5.bin OK

Building firmware for 4MB Flash, Flash map: 6 (1024+1024)
File size = 435396
esp8266_AT_1_6.bin OK

=====================================

https://www.fosslinux.com/39384/switching-between-python-2-and-3-versions-on-ubuntu-20-04.htm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants