Upgrade your OctoPrint install to Python 3!

It returns the following, but I don't actually understand what it means.

venv error - Copy.log (1.6 KB)

I deliberately did not send you the full command, since then it would have started creating a full virtual environment. That seems to work. I will send you a custom version of the script, since I don't want it to break for everyone else.

1 Like

Try this:

curl -L https://github.com/cp2004/Octoprint-Upgrade-To-Py3/raw/virtualenv-py3/upgrade.py --output upgrade.py
python3 upgrade.py

You should get V2.1.9.

Let me know if you run into any more issues (:crossed_fingers:)

1 Like

"Cleaning up...
Finished! OctoPrint should be ready to go"

I greatly appreciate your help and the time you spent on my issues.
Thank you :slight_smile: :beers:

1 Like

This script ran without error. Thank you. One question, when I ssh in and run python --version it replies back with 2.7.16 however I can execute python3 and see it running. My question is how can I verify Octoprint is calling python3 and not python2 ?

Thank you

1 Like

The web ui tells you at the bottom.

1 Like

Excellent thank you!

Two updates went fine, but the third gave me this error:


Collecting required packages
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple wrapt/wrapt-1.12.1-cp37-cp37m-linux_armv7l.whl

Restarting gave mi this:


Detecting system info...
OctoPi version: 0.17.0
Unable to parse Python version string. Please report to me the line below that has caused problems....
[]
Virtual environment is already Python 3, are you sure you need an upgrade?

If you'd rather upgrade a different virtual env, you can enter the full path here
Path:

And got this:


Detecting system info...
OctoPi version: 0.17.0
Traceback (most recent call last):
  File "upgrade.py", line 605, in <module>
    path_to_venv, commands, config_dir = get_env_config(octopi_valid)
  File "upgrade.py", line 268, in get_env_config
    if venv_path and not check_venv_python(venv_path):
  File "upgrade.py", line 359, in check_venv_python
    print_c("Unable to parse Python version string. Please report to me the line below that has caused problems....")
TypeError: print_c() missing 1 required positional argument: 'color'

And yes, no OctoPrint on it:

------------------------------------------------------------------------------
OctoPrint version : unknown
OctoPi version    : 0.17.0
------------------------------------------------------------------------------

Managed it:

  • Made removed the faulty oprint folder
  • made a copy of oprint.bak to oprint
  • restarted the process and runs fine

That looks to me like a network issue - not an error generated by the script, so must be pip. Something dropped out during the process is likely why that failed.

And the go_back.py script does exactly what you mention below to put the old install back :slightly_smiling_face:.

Great that it worked in the end :smiley:

1 Like

Oh and this exception was fixed in a commit I pushed earlier today, it should be working fine for fresh downloads.

1 Like

One thing I did before the upgrade was a quick house keeping of the disabled plug ins. I simply deleted all the disabled ones from in the plug in manager.

Four OctoPi 0.17's upgraded from 1.4.0 to 1.4.2, then after reading the whole post/Instructions from @Charlie_Powell ran the Python script with no errors on all four. Brilliant.

Thank you @Charlie_Powell and @foosel - I cannot express the gratitude for writing clear instructions on how to do this. People just need to take the time and read this all first.

If you aren't on OctoPi 0.17 then perhaps you should simply do a backup, buy a new microSD and load a fresh image and upgrade it, then restore your backup to it. You already have a year on the old microSD since 0.17 came out, and probably have unplugged the power instead of doing a proper shut down at least once. Cost for a suitable card is cheap. Just do it.

Looking forward to seeing that yellow Python 2 status line drop like a rock... Go Python 3 Green!

1 Like

@m.hutchinson - Thank you so much for all the positive feedback. It's very much appreciated by both myself and @foosel. I also love seeing a reply here that I can read and appreciate, rather than having to figure out what went wrong! :smile:
I'm also looking forward to the moment when Python 3 installs overtake Python 2 :partying_face:

@Charlie_Powell You are welcome. Often we don't take the time to say when things go right, only when things go wrong. I see a lot of dissuaded new users respond thinking only problems exist, not success.

1 Like

@foosel

Next step may be to ask Guy Sheffer to release OctoPi 0.18.0 with Python 3 installed and help deprecate Python 2. That would also be a chance to get Octoprint 1.42 pre-loaded.

1 Like

I am well aware of next steps :wink:

2 Likes

Hello, I checked if the plugins I installed support Python3 and it's ok, so I ran
"curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py python3 upgrade.py"

But I have a mistake:
curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py python3 upgrade.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 154 100 154 0 0 1540 0 --:--:-- --:--:-- --:--:-- 1555
100 25069 100 25069 0 0 117k 0 --:--:-- --:--:-- --:--:-- 117k
curl: (6) Could not resolve host: python3
curl: (6) Could not resolve host: upgrade.py

can you help me to handle it ?
Thank you

the section python3 upgrade.py should be the second command, it looks like yours may be thinking it is the same command.

1 Like

indeed, thank you very much
image

1 Like

i have an error :slight_smile:

python3-dev is reeds de nieuwste versie (3.7.3-1). is already the newest version
Traceback (most recent call last):
File "upgrade.py", line 595, in
install_python3_dev(backup_location)
File "upgrade.py", line 430, in install_python3_dev
output, poll = run_sys_command(['sudo', 'apt-get', 'install', 'python3-dev', '-y'], sudo=True)
File "upgrade.py", line 105, in run_sys_command
output_line = process.stdout.readline().decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xef in position 27: invalid continuation byte

sorry for the dutch
upgrade.py stopped also with -f -d
greatings jul