Giter Club home page Giter Club logo

octoprint-upgrade-to-py3's Introduction

Upgrade your OctoPrint install to Python 3!

Many new plugins only support Python 3, and do not support Python 2 anymore. If you get a message like this installing a plugin:

ERROR: Package 'OctoDash-Companion' requires a different Python: 2.7.16 not in '>=3.3, <4'

You need to upgrade your OctoPrint install to use Python 3, rather than Python 2.

You have several options, depending on how you have installed OctoPrint:

Re-flashing your OS

This is the easiest way to upgrade if you are using OctoPi, since you can re-flash the base OS and it is using Python 3.

  1. Take a backup from inside OctoPrint's 'Backup and Restore' tab, and download it.
  2. Download & install OctoPi 0.18
  3. Once installed, you can restore your backup using 'Backup and Restore' again.

Using this script

Requirements

  • Python 3.6+ installed as python3 on the system
  • Linux install
  • OctoPrint 1.4.0+ for Python 3 compatibility. Note: The script will install the latest stable version of OctoPrint when you run it.

If you don't meet the above requirements, then please see 'What can I do if my system is not supported' below.

Running the script

Run the following 2 commands in the OS terminal (either through SSH or a connected keyboard/monitor) to start the upgrade:

curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py
python3 upgrade.py

If you are not running OctoPi, you will be prompted to provide:

  • The path to the venv (/home/pi/oprint on OctoPi)
  • Configuration directory (/home/pi/.octoprint)
  • Command to stop (sudo service octoprint stop)
  • Command to start (sudo service octoprint start)

You may also be asked to provide the sudo password so the script can install python3-dev, a package required to install some plugins. (If your machine is not running passwordless sudo)

Once the install has finished (and you have tested it works, of course) you can safely remove the folder /path/to/venv.bak containing your old Python 2 environment.

On an OctoPi install, this would be at /home/pi/oprint.bak

Command line options

There are two command line options available, which you can use. Both optional:

  • -f or --force: Forces through any 'confirmations' where you would have to press enter to continue. Note that you may still need to enter your configuration or sudo password.
  • -c or --custom: Force use of custom input, as would be standard on non-OctoPi installs. Useful if you have multiple installs, but started on OctoPi.

Returning to the old install

If the install fails, then you can safely return to the old install by restoring the backup. It is just the old environment renamed, so you can move it back to it's original position.

You can use the other script in this repo, go_back.py to return to the old install. Usage is similar to the upgrade script:

curl -L https://raw.githubusercontent.com/cp2004/Octoprint-Upgrade-To-Py3/master/go_back.py --output go_back.py
python3 go_back.py

What do I do if my system is not supported?

OctoPi 0.16 or earlier

OctoPrint is only compatible with Python 3.6+. As a result, on earlier versions of OctoPi that were not based on Debian Buster, it is not possible to run this script on those OctoPi versions, since they don't have a new enough Python install available.

Recommended route to Python 3

Manual installs

If you are running Windows, MacOS or your system does not work with this script for whatever reason, then you will need to perform the upgrade manually.

The basic steps boil down to this:

  • Create a backup of your OctoPrint install (not available on Windows)
  • Save a copy of your current virtual environment
  • Create a new virtual environment based on Python 3
  • Install OctoPrint in the virtual environment
  • Restore the backup you downloaded earlier.

For more detailed steps, please refer to the OS specific install guides on the download page

Blog post

For a full explanation of why this script is here, please make sure to read the blog post I wrote about this on the OctoPrint blog: Upgrade Your OctoPrint Install to Python 3!

Limitations of this script

  • The script is unable to restore plugins that are not on the official repository. If it cannot find the plugin listed it will tell you and you should install them manually afterwards.

  • The script is not able to tell you if your plugins are not Python 3 compatible, you will have to check in the OctoPrint plugin manager afterwards to find incompatible ones. Recommended to check before upgrading.

Contributing

Please open an issue if you find something wrong, or have a feature request. If you would like to make a PR, please do so against the devel branch as master is the download branch for users and I don't want changes that accidentally break something! If your are making a PR for a big feature, please open an issue first so we can discuss.

Sponsors

As well as 2 others supporting me regularly through GitHub Sponsors!

Supporting my efforts

GitHub Sponsors

I created this project in my spare time, and do my best to support the community with issues and help using it. If you have found this useful or enjoyed using it then please consider supporting it's development! ❤️. You can sponsor monthly or one time, for any amount you choose.

Check out my other plugins

You can see all of my published OctoPrint plugins on the OctoPrint Plugin Repository! Or, if you're feeling nosy and want to see what else I'm working on, check out my GitHub profile.

🔨

octoprint-upgrade-to-py3's People

Contributors

cp2004 avatar foosel avatar j-cmartin avatar jasonbcox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

octoprint-upgrade-to-py3's Issues

Upgrade failed to do anything at all...

Script did not work... Why can't this be updated from the octoprint interface like the plugins??? This is difficult for a non-linux person. I do not understand this stuff. trying to look up how to install this python update created 10 more questions and no answers that make any sense.

Image1

[Bug] The script runs but does not complete, ending with FileNotFoundError

Describe the bug
The script runs but does not complete, ending with an error message as described below. No upgrade is performed.

Script output
Output of the script follows

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
Traceback (most recent call last):
  File "upgrade.py", line 556, in <module>
    plugin_keys = read_plugins_from_backup(backup_location)
  File "upgrade.py", line 363, in read_plugins_from_backup
    with zipfile.ZipFile(backup_path, 'r') as zip_ref:
  File "/usr/lib/python3.7/zipfile.py", line 1204, in __init__
    self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/.octoprint/data/backup/octoprint-backup-20200911-103600.zip'
root@octopi:~# Connection to octopi.centauri.lan closed by remote host.
Connection to octopi.centauri.lan closed.

Script version
2.0.4

OctoPrint Version
OctoPrint 1.4.2

Relevant plugins that may have caused errors
If you're having trouble with a particular part, please include your installed plugins > Nothing observed indicating the issue relates to a plugin.

Additional information
Screenshot attached showing full output during attempted upgrade.
Screen Shot 2020-09-11 at 10 41 46 am

[BUG] Upgrade fails in 1.4.1

Describe the bug
New to this so pls excuse any inproprieties. When running upgrade I came across
Traceback (most recent call last):
File "upgrade.py", line 219, in
backup_target = re.search(r'(?<=Backup located at )(.*)(?=.zip)', backup_path_line).group()
AttributeError: 'NoneType' object has no attribute 'group'

Potential fixes
backup_target = re.search(r'(?<=Backup located at )(.*)(?=.zip)', backup_path_line).group()
fails because "Backup located at" output from backup command is not saved.
Adding the filling worked for me.
206 if 'Backup' in output:
207 backup_path_line = output

Script output
Please paste the output of the script here

pi@alderaan:~ $ python3 upgrade.py
OctoPrint Upgrade from Python 2 to Python 3 (v1.3.6)
This script requires an internet connection and it will disrupt any ongoing print jobs.
It will install the latest OctoPrint (1.4.0) and all plugins.
No configuration or other files will be overwritten
Testing: False
Press [enter] to continue or ctrl-c to quit

Detected OctoPi installation
Checking version
OctoPrint version: 1.4.1

Creating a backup so we can read the plugin list
Creating backup at octoprint-backup-20200805-193423.zip, please wait...

Traceback (most recent call last):
  File "upgrade.py", line 219, in <module>
    backup_target = re.search(r'(?<=Backup located at )(.*)(?=.zip)', backup_path_line).group()
AttributeError: 'NoneType' object has no attribute 'group'

OctoPrint Version
Octoprint 1.4.1

Plugins installed & versions
Plugins installed:

  • Floating Navbar
  • Python 3 Check
  • Bed Visualizer
  • PSU Control
  • BLTouch Plugin
  • Simple Emergency Stop
  • Cancel Objects
  • Resource Monitor
  • Octohue
  • Tab Order
  • Themeify
  • Autoscroll
  • Navbar Temperature Plugin

Additional information
Screenshots, links to docs, etc.

[Bug] Updating to Python3 failed with SpaghettiDetective, no connection available anymore

Describe the bug

Updating octoprint to pyhton 3 failed, now the server is not starting and I am not able to ssh to it

Script output
Please paste the complete output of the script in the box below:

pi@octopi:~ $ python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.2.2)

This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Checking system info...
Detected OctoPi version 0.17.0
Found version: Python 2.7.16
Checking OctoPrint version...
OctoPrint version: 1.7.2
Reading installed plugins...

Plugins installed
- Tasmota
- Telegram Notifications
- Draggable Files
- Access Anywhere - The Spaghetti Detective
- DisplayZ
- BetterHeaterTimeout
- MeatPack
- Autoselect Plugin
- M73 Progress Plugin
- Dragon Order
- Tab Order
- Themeify
- Autoscroll
- Fullscreen Plugin
- TouchUI
- OctoEverywhere!
- Bed Visualizer
- Simple Emergency Stop
- Backup Scheduler
- Navbar Temperature Plugin
- Marlin EEPROM Editor
- Preheat Button
If you think there is something missing from here, please check the list of plugins in OctoPrint
Press [enter] to continue or ctrl-c to quit

Updating package list...

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for pi:

Checking package list for python3-dev
Installing python3-dev...
Successfully installed python3-dev
Checking package list for python3-venv
Installing python3-venv...
Successfully installed python3-venv
Creating new Python 3 environment...
Successfully created Python 3 environment at /home/pi/oprint
Installing build dependencies...
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
Updating pip...
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored

Installing OctoPrint... (This may take a while - Do not cancel!)
Collecting required packages
Installing collected packages
OctoPrint successfully installed!

Downloading OctoPrint's plugin repo

Installing Navbar Temp
Collecting required packages
Installing collected packages
Plugin Navbar Temp successfully installed
Installing Autoselect
Collecting required packages
Installing collected packages
Plugin Autoselect successfully installed
Installing Marlin EEPROM Editor
Collecting required packages
Installing collected packages
Plugin Marlin EEPROM Editor successfully installed
Installing DisplayZ
Collecting required packages
Installing collected packages
Plugin DisplayZ successfully installed
Installing TouchUI
Collecting required packages
Installing collected packages
Plugin TouchUI successfully installed
Installing OctoPrint-Telegram
Collecting required packages
Installing collected packages
Plugin OctoPrint-Telegram successfully installed
Installing Autoscroll
Collecting required packages
Installing collected packages
Plugin Autoscroll successfully installed
Installing Fullscreen Webcam
Collecting required packages
Installing collected packages
Plugin Fullscreen Webcam successfully installed
Installing Simple Emergency Stop
Collecting required packages
Installing collected packages
Plugin Simple Emergency Stop successfully installed
Installing Themeify
Collecting required packages
Installing collected packages
Plugin Themeify successfully installed
Installing Preheat Button
Collecting required packages
Installing collected packages
Plugin Preheat Button successfully installed
Installing OctoPrint-Tasmota
Collecting required packages
Installing collected packages
Plugin OctoPrint-Tasmota successfully installed
Installing M73 Progress
Collecting required packages
Installing collected packages
Plugin M73 Progress successfully installed
Installing OctoPrint-TabOrder
Collecting required packages
Installing collected packages
Plugin OctoPrint-TabOrder successfully installed
Installing Bed Level Visualizer
Collecting required packages
Installing collected packages
Plugin Bed Level Visualizer successfully installed
Warning: You have installed Bed Level visualiser. There is a known issue with it failing silently on Python 3
See more here: https://github.com/jneilliii/OctoPrint-BedLevelVisualizer#known-issues
Installing OctoPrint-DragonOrder
Collecting required packages
Installing collected packages
Plugin OctoPrint-DragonOrder successfully installed
Installing OctoPrint-BetterHeaterTimeout
Collecting required packages
Installing collected packages
Plugin OctoPrint-BetterHeaterTimeout successfully installed
Installing Access Anywhere - The Spaghetti Detective
Collecting required packages
Error installing package
  Building wheel for TheSpaghettiDetective (setup.py): finished with status 'error'

Connection to octopi.local closed by remote host.
Connection to octopi.local closed.

Script version
You can find this printed in the first line of the script

OctoPrint Version
OctoPrint 1.7.2

Relevant plugins that may have caused errors
If you're having trouble with a particular part, please include your installed plugins

Additional information
Screenshots, links to docs, etc.

Any idea what I can do to restore my octoprint? I am not able to acces it now, even going back to python 2 will be fine for me

[Bug] AttributeError Octolapse on running script

Describe the bug
When running the script I get the following AttributeError. I can still continue the installation though.
Seems to be caused by something related to octolapse, but as this is a popular plugin it might be worth to check what is going on?

Script output

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
No handlers could be found for logger "octoprint.plugin.core"
2020-09-20 11:27:33,148 - octolapse.__init__ - INFO - Release mode detected.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.7/logging/__init__.py", line 1676, in shutdown
    h.close()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 32, in close
    self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.7/logging/__init__.py", line 1676, in shutdown
    h.close()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 32, in close
    self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'

Plugins installed
- Floating Navbar
- HeaterTimeout
- PSU Control
- Progress Title
- Gcodebar Plugin
- TemperatureFailsafe
- Octolapse
- Bed Visualizer
- Themeify
- Navbar Temperature Plugin
If you think there is something missing from here, please check the list of plugins in Octoprint
Press [enter] to continue or ctrl-c to quit

Script version
v2.1.7

OctoPrint Version
OctoPrint 1.4.2

Relevant plugins that may have caused errors
The error mentions Octolapse.

[Bug] OctoPrint-ExcludeRegionPlugin - Not working with Py3

Describe the bug
Enabling or redownloading the https://github.com/bradcfisher/OctoPrint-ExcludeRegionPlugin pluggin.
Restart the OctoPi instance.
Boot up and the plugin is disabled.

Script output
Please paste the output of the script in the box below:

HERE

Script version
Printed at the very top of the script

OctoPrint Version
OctoPrint 1.4.2

Relevant plugins that may have caused errors
https://github.com/bradcfisher/OctoPrint-ExcludeRegionPlugin

Additional information
2020-09-14 21_02_20-Window

[Bug] When I run the script, it says that I'm already at Python 3, but I'm not

OP 1.4.2. Latest version of the script. 2.1.6

When I run the script, I get this error: "Virtual environment is already Python 3, are you sure you need an upgrade?"

Charlie figured this part out, I'm just summarizing the discussion from the forum.
The reason for this is that the venv/bin/python exectuable version outputs as 2.7.15+, with the '+' being the problem. Charlie said he changed the code to drop the '+', but I'm still getting the error.

I don't know much Python, but to troubleshoot, I add the following debug to around line 344, which is where the version check takes place(I think).

print("1") print(line) if line.endswith("+"): line = line[:-1] print("2") print("3") print(line)
When I run that, I get the following output. This leads me to believe that the IF statement is not evaluating to true, even though it seems like it obviously should evaluate to true. On a hunch, I thought maybe there is whitespace at the end of the string, and sure enough, when I added a line = line.strip() right before the IF statement, it started working properly. Please take a look and make sure that isn't something crazy that I did. I'll probably wait to hear back from you before proceeding.

`Path: /home/hass/OctoPrint/venv
1
Python 2.7.15+

3
Python 2.7.15+

Virtual environment is already Python 3, are you sure you need an upgrade?
Please try again
Path:
`

[Bug] Can't find Backup

Describe the bug
The backup does not appear to be generated, so the script can't get plugin from backup.
So an error is generated.

Script output
Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
Traceback (most recent call last):
File "upgrade.py", line 556, in
plugin_keys = read_plugins_from_backup(backup_location)
File "upgrade.py", line 363, in read_plugins_from_backup
with zipfile.ZipFile(backup_path, 'r') as zip_ref:
File "/usr/lib/python3.7/zipfile.py", line 1204, in init
self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/.octoprint/data/backup/octoprint-backup-20200911-075652.zip'

Script version
OctoPrint Upgrade to Py 3 (v2.0.4)

OctoPrint Version
OctoPrint 1.4.2

Relevant plugins that may have caused errors

Additional information

Script doesn't work if octoprint user (pi) doesn't have Superuser priveleges [Bug]

Describe the bug
On my setup, user pi has only specific sudo privileges (systemctl start/stop/restart octoprint.service). Script asks to install python3-dev, but doesn't check if it is already installed. If i try to run the script, i can't proceed past sudo prompt for sudo apt-get update in function install_python3_dev

Script version
v2.1.12

OctoPrint Version
OctoPrint 1.5.2

Additional information
I have added function check_python3_dev that uses dpkg-query -l to list installed packages and checks if output contains python3-dev. It replaces install_python3_dev in program flow, and calls that function only if the package is not present. It fixed my (and maybe others) problem and i believe it doesn't break anything. I will try to make a PR with my fix, i'm not too familiar with Github, so i hope i'll manage to do it, tho. = D

[Bug] JSON error starting upgrade

Describe the bug
I attempted to upgrade my Octoprint and ran into an error. Right after the Reading installed plugins... it threw an exception.

Script output
Please paste the output of the script in the box below:

╰─➤  python3 upgrade.py 
OctoPrint Upgrade to Py 3 (v2.0.3)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint (1.4.2) and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
Please provide the path to your virtual environment and the config directory of OctoPrint
On OctoPi, this would be /home/pi/oprint and commands 'sudo service octoprint stop/start'
Path: /home/pi/.octoprint
Invalid venv path, please try again
Path: home/pi/.virtualenvs/octoprint
Invalid venv path, please try again
Path: /home/pi/.virtualenvs/octoprint
Path valid
Config directory: /home/pi/.octoprint
Config directory valid

To do the install, we need the service stop and start commands. (Leave blank if you don't have a service set up)
Stop command: systemctl stop octoprint.service
Start command: systemctl start octoprint.service
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
Traceback (most recent call last):
  File "upgrade.py", line 555, in <module>
    plugin_keys = read_plugins_from_backup(backup_location)
  File "upgrade.py", line 371, in read_plugins_from_backup
    plugin_list = json.load(plugins)
  File "/usr/lib/python3.5/json/__init__.py", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

Script version
v2.0.3

OctoPrint Version
OctoPrint 1.4.2

Relevant plugins that may have caused errors
N/A

Additional information
None

X server needed to run that script ?

Describe the bug
after dowenloading the script I made it executable using sudo chmod +x upgrade.py and I executed the script using sudo.
Right after that the script is telling me that its not able to open the X server

Script output
Please paste the complete output of the script in the box below:

sudo ./upgrade.py
import-im6.q16: unable to open X server `' @ error/import.c/ImportImageCommand/360.
./upgrade.py: 19: ./upgrade.py: Syntax error: "(" unexpected (expecting "then")

Script version
SCRIPT_VERSION = '2.2.0'

OctoPrint Version
octoprint.version: 1.6.1

Relevant plugins that may have caused errors
If you're having trouble with a particular part, please include your installed plugins

Additional information
Screenshots, links to docs, etc.
Screenshot_1

wheel is not automatically installed

The install script does not automatically install the wheel package for debian/pip, resulting in "fake" errors that can scary people out and slow plugin install times. Note that octoprint and plugins do install correctly with the traditional setup.py install.

Script output
For every package:

Failed building wheel for Octolapse
  error: invalid command 'bdist_wheel'

Script version
You can find this printed in the first line of the script
It's not actually the first line, but it's 2.1.16

OctoPrint Version
OctoPrint 1.6 kind of

[BUG] OctoPrint 1.4.1rc4 Upgrade Failure

upgrade script fails with OctoPrint 1.4.1RC4.

Detected OctoPi installation
Checking version
OctoPrint version: 1.4.1rc4
Traceback (most recent call last):
  File "upgrade.py", line 138, in <module>
    OPRINT_GT_141 = oprint_version_gt_141(PATH_TO_VENV)
  File "upgrade.py", line 57, in oprint_version_gt_141
    if int(version_no[2]) > 0:
ValueError: invalid literal for int() with base 10: '1rc4'

[Bug] Repository changed its "Suite"

Upgrade failed:

E: Repository 'http://raspbian.raspberrypi.org/raspbian buster InRelease' changed its 'Suite' value from 'testing' to 'stable'
ERROR: failed to update package list

Upgrade steps:

pi@octopi:~ $ curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 154 100 154 0 0 1107 0 --:--:-- --:--:-- --:--:-- 1107
100 23883 100 23883 0 0 43983 0 --:--:-- --:--:-- --:--:-- 96302
pi@octopi:~ $ python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.1.3)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint (1.4.2) and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...

Plugins installed

  • DisplayLayerProgress Plugin
  • Detailed Progress
  • Filament Manager
  • FileManager
  • Cost Estimation
  • Dashboard
  • Sidebar Webcam
    If you think there is something missing from here, please check the list of plugins in Octoprint
    Press [enter] to continue or ctrl-c to quit

Root access is required to install python3-dev, please fill in the password prompt if shown
Updating package list...
[sudo] password for pi:
E: Repository 'http://raspbian.raspberrypi.org/raspbian buster InRelease' changed its 'Suite' value from 'testing' to 'stable'
ERROR: failed to update package list
Please try manually

Cleaning up...
Fatal error: Exiting

Another Upgrade for a second printer worked well, without problems.

Many Thaks Udo

[Bug] Pip errors as wheel is not working properly *sometimes*.

See comments in #44

Wheel should be automatically installed, and no errors are reported from this process. But sometimes it shows up loads of error messages installing other packages.

The upgrade does actually succeed. Pip is smart enough to work around the issues and get you running any way possible. Please don't panic, but if you know what you are looking at please think of any possible solutions and let me know. I don't know what to do here and have very little time for a proper investigation dive into it at the moment.

OctoLapse traceback in detecting plugins (do not worry - upgrade unaffected!)

Describe the bug
there is an error after detecting the system.
both in python27 files

Script output
Please paste the output of the script in the box below:


pi@octopi:~ $ curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   154  100   154    0     0    275      0 --:--:-- --:--:-- --:--:--   275
100 22216  100 22216    0     0  31202      0 --:--:-- --:--:-- --:--:-- 31202
pi@octopi:~ $   python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.0.3)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint (1.4.2) and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
2020-09-10 13:11:47,024 - octolapse.__init__ - INFO - Release mode detected.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.7/logging/__init__.py", line 1676, in shutdown
    h.close()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 32, in close
    self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.7/logging/__init__.py", line 1676, in shutdown
    h.close()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 32, in close
    self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'

Plugins installed
- DisplayLayerProgress Plugin
- Firmware Updater
- Detailed Progress
- PrettyGCode
- Webcam Iframe
- BetterHeaterTimeout
- RaiseCloud
- Themeify
- Resource Monitor
- Z Probe Offset
- Bed Visualizer
- PrintTimeGenius Plugin
- Simple Emergency Stop
- TP-Link Smartplug
- Navbar Temperature Plugin
- Marlin Flasher
- Change Filament Plugin
- Exclude Region
- Dashboard
- Floating Navbar
- EEPROM Marlin Editor Plugin
- Marlin Binary File Transfer: Protocol Mk II
- Octolapse
If you think there is something missing from here, please check the list of plugins in Octoprint
Press [enter] to continue or ctrl-c to quit

Script version
2.0.3

OctoPrint Version
OctoPrint 1.4.2

Relevant plugins that may have caused errors
If you're having trouble with a particular part, please include your installed plugins

Additional information
Screenshots, links to docs, etc.

[Bug] python3 segfaults after upgrade

Describe the bug
After successfully running the upgrade script python3 segfaults.
Even running it as another user (root) segfaults, so I guess it has nothing to do with the environment.

Script output

pi@octopi:~ $   python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.1.7)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint (1.4.2) and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.1
Reading installed plugins...
2020-09-21 11:25:59,158 - octolapse.__init__ - INFO - Release mode detected.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.7/logging/__init__.py", line 1676, in shutdown
    h.close()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 32, in close
    self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.7/logging/__init__.py", line 1676, in shutdown
    h.close()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 32, in close
    self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'

Plugins installed
- DisplayLayerProgress Plugin
- LayerDisplay
- Floating Navbar
- Preheat Button
- Printoid Plugin
- GcodeEditor
- Smart Preheat
- The Spaghetti Detective
- Cancel Objects
- FileManager
- Octolapse
- Bed Leveling Wizard
- PrusaSlicer Thumbnails
- Themeify
- PrintTimeGenius Plugin
- Navbar Temperature Plugin
If you think there is something missing from here, please check the list of plugins in Octoprint
Press [enter] to continue or ctrl-c to quit

Root access is required to install python3-dev, please fill in the password prompt if shown
Updating package list...
Installing python3-dev...
Successfully installed python3-dev
Creating new Python 3 environment...
/usr/lib/python2.7/dist-packages/virtualenv.py:1090: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Successfully created Python 3 environment at /home/pi/oprint

Installing OctoPrint... (This may take a while - Do not cancel!)
Collecting required packages
Installing collected packages
OctoPrint successfully installed!

Downloading OctoPrint's plugin repo

Installing Navbar Temp
Collecting required packages
Installing collected packages
Plugin Navbar Temp successfully installed
Installing FileManager
Collecting required packages
Installing collected packages
Plugin FileManager successfully installed
Installing GcodeEditor
Collecting required packages
Installing collected packages
Plugin GcodeEditor successfully installed
Installing Themeify
Collecting required packages
Installing collected packages
Plugin Themeify successfully installed
Installing Preheat Button
Collecting required packages
Installing collected packages
Plugin Preheat Button successfully installed
Installing OctoPrint-FloatingNavbar
Collecting required packages
Installing collected packages
Plugin OctoPrint-FloatingNavbar successfully installed
Installing Octolapse
Collecting required packages
Installing collected packages
Plugin Octolapse successfully installed
Installing DisplayLayerProgress
Collecting required packages
Installing collected packages
Plugin DisplayLayerProgress successfully installed
Installing OctoPrint-Cancelobject
Collecting required packages
Installing collected packages
Plugin OctoPrint-Cancelobject successfully installed
Installing OctoPrint-PrintTimeGenius
Collecting required packages
Installing collected packages
Plugin OctoPrint-PrintTimeGenius successfully installed
Installing LayerDisplay
Collecting required packages
Installing collected packages
Plugin LayerDisplay successfully installed
Installing OctoPrint-BedLevelingWizard
Collecting required packages
Installing collected packages
Plugin OctoPrint-BedLevelingWizard successfully installed
Installing Access Anywhere - The Spaghetti Detective
Collecting required packages
Installing collected packages
Plugin Access Anywhere - The Spaghetti Detective successfully installed
Installing PrusaSlicer Thumbnails
Collecting required packages
Installing collected packages
Plugin PrusaSlicer Thumbnails successfully installed
Installing OctoPrint-Printoid
Collecting required packages
Installing collected packages
Plugin OctoPrint-Printoid successfully installed
Installing Smart Preheat
Collecting required packages
Installing collected packages
Plugin Smart Preheat successfully installed

Cleaning up...
Finished! OctoPrint should be ready to go
Once you have verified the install works, you can safely remove the folder /home/pi/oprint.bak
If you want to go back (If it doesn't work) to Python 2 download the file at: 
https://raw.githubusercontent.com/cp2004/Octoprint-Upgrade-To-Py3/master/go_back.py
pi@octopi:~ $
pi@octopi:~ $ python --version
Python 2.7.16
pi@octopi:~ $ python3 --version
Segmentation fault
pi@octopi:~ $ sudo su -

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

root@octopi:~# python3
Segmentation fault
root@octopi:~# logout

Script version
OctoPrint Upgrade to Py 3 (v2.1.7)

OctoPrint Version
OctoPrint 1.4.1

FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/.octoprint/data/backup/octoprint-backup-20200910-160051.zip'

Describe the bug
Running the upgrade script fails.

Script output
Please paste the output of the script in the box below:

root@octopi:/home/pi# python3 upgrade.py 
OctoPrint Upgrade to Py 3 (v2.0.3)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint (1.4.2) and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
Traceback (most recent call last):
  File "upgrade.py", line 555, in <module>
    plugin_keys = read_plugins_from_backup(backup_location)
  File "upgrade.py", line 362, in read_plugins_from_backup
    with zipfile.ZipFile(backup_path, 'r') as zip_ref:
  File "/usr/lib/python3.7/zipfile.py", line 1204, in __init__
    self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/.octoprint/data/backup/octoprint-backup-20200910-160051.zip'

Script version
Printed at the very top of the script

OctoPrint Version
OctoPrint 1.4.2

Plugins are not installed?

Hi.
I performed the steps, I have Octopi Version 0.17.0, running on Raspberry Pi 4 Model B Rev 1.2, and Octoprint Version 1.4.2.
I ran into the following issue, where no plugins were installed. So I used the go_back script, which worked!

From the terminal session:
Successfully created Python 3 environment at /home/pi/oprint

Installing OctoPrint... (This may take a while - Do not cancel!)
Collecting required packages
Installing collected packages
OctoPrint successfully installed!
Required dependency requests is missing... No plugins can be installed
OctoPrint has been installed, but no plugins have

[Bug] After seemingly successful update to python 3, "Software Update" is disabled

Describe the bug

After following https://octoprint.org/blog/2020/09/10/upgrade-to-py3/ "Software Update" is blocked b/c of unexpected versions.

Screen Shot 2021-11-06 at 2 19 36 PM

It's showing lots of updates available, but the button is disabled:

Screen Shot 2021-11-06 at 2 22 29 PM

Everything seems to work fine. I'm able to print and haven't run across anything else broken or unhappy. I'll probably look at a fresh install and import my config, but figured I'd file this and give a bit of time to see if there's any information you all would like me to collect or anything you'd like me to try out/dig into.

Script output

I didn't see anything noteworthy during the process and I've long since closed the terminal I ran it in. If the log is on disk somewhere lmk and I can grab it. It wasn't until today (about a week later) that I I got the updates available popup and went to update, but couldn't.

Script version

Same

OctoPrint Version

OctoPrint 1.7.0

[Bug] Describe your bug

It is not a bug, it is a question.
If I don't use virtual env, which path should I add there? Nothing seems to work.

Fails to create venv, [Request] --debug flag to print *everything* to the terminal

Is there manual way to restore backup?
Script failed and go_back.py too :-(

Manual install detected
Please provide the path to your virtual environment
Path: /home/pi/OctoPrint/venv.bak
Venv found

To revert the install, we need the service stop and start commands for OctoPrint
Stop command: sudo service octoprint stop
Start command: sudo service octoprint start
mv: nelze získat informace o '/home/pi/OctoPrint/venv.bak.bak': Adresář nebo soubor neexistuje
ERROR: failed to restore backup
Please try manually
Exiting

Now backup file looks like this:

pi@octobuntu:~/OctoPrint$ ls
venv.bakFAIL.bak

I hope that restore is still possible... I have to make double backup next time.

[Bug] AttributeError: 'BackupPlugin' object has no attribute '_logger'

Describe the bug

Script output
Please paste the complete output of the script in the box below:

pi@octopi:~ $ curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   154  100   154    0     0    729      0 --:--:-- --:--:-- --:--:--   729
100 25622  100 25622    0     0  46082      0 --:--:-- --:--:-- --:--:-- 46082
pi@octopi:~ $   python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.1.11)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint (1.4.2) and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.5.0rc1
Reading installed plugins...
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/pi/oprint/lib/python2.7/site-packages/octoprint/__main__.py", line 8, in <module>
    octoprint.main()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/__init__.py", line 939, in main
    octo(args=args, prog_name="octoprint", auto_envvar_prefix="OCTOPRINT")
  File "/home/pi/oprint/local/lib/python2.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/pi/oprint/local/lib/python2.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/pi/oprint/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/backup/__init__.py", line 504, in backup_command
    logger=self._logger,
AttributeError: 'BackupPlugin' object has no attribute '_logger'
ERROR: Failed to create OctoPrint backup
Fatal error, exiting

Script version
OctoPrint Upgrade to Py 3 (v2.1.11)

OctoPrint Version
OctoPrint 1.5.0rc1

Relevant plugins that may have caused errors
BackupPlugin ?

Additional information
I'm just giving feedback on trying to switch to Python3 (Python3.7.3 in this case)

[Bug] UnicodeDecodeError running `sudo apt-get update`

Describe the bug
Upgrade script exits with error (see below)

Script output
Please paste the complete output of the script in the box below:
pi@octopi:~ $ curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 154 100 154 0 0 1495 0 --:--:-- --:--:-- --:--:-- 1495
100 27452 100 27452 0 0 84728 0 --:--:-- --:--:-- --:--:-- 84728

pi@octopi:~ $ python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.2.1)

This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Checking system info...
Detected OctoPi version 0.17.0
Checking OctoPrint version...
OctoPrint version: 1.7.0
Reading installed plugins...

Plugins installed

  • GPIO Control
    If you think there is something missing from here, please check the list of plugins in OctoPrint
    Press [enter] to continue or ctrl-c to quit

Updating package list...
Checking package list for python3-dev
Installing python3-dev...
Traceback (most recent call last):
File "upgrade.py", line 679, in
run_apt_install("python3-dev", backup_location)
File "upgrade.py", line 177, in run_apt_install
output, poll = run_sys_command(["sudo", "apt-get", "install", package, "-y"], sudo=True)
File "upgrade.py", line 118, in run_sys_command
print(output_line, end="")
UnicodeEncodeError: 'latin-1' codec can't encode character '\ufffd' in position 14: ordinal not in range(256)
pi@octopi:~ $ Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='ISO-8859-1'>
BrokenPipeError: [Errno 32] Daten�bergabe unterbrochen (broken pipe)
E: Unterprozess /usr/bin/apt-listchanges --apt || test $? -lt 10 hat Fehlercode zur�ckgegeben (1)
E: Failure running script /usr/bin/apt-listchanges --apt || test $? -lt 10

Script version
You can find this printed in the first line of the script
v2.2.1

OctoPrint Version
OctoPrint 1.7.0

Relevant plugins that may have caused errors
If you're having trouble with a particular part, please include your installed plugins

Additional information
Screenshots, links to docs, etc.

confirm_no_root & os has no attribute geteuid

I get this message at running the script.

C:\OctoPrint\venv\Scripts>python3 upgrade.py
Traceback (most recent call last):
File "upgrade.py", line 570, in
if not confirm_no_root() and not args.iknowwhatimdoing:
File "upgrade.py", line 177, in confirm_no_root
euid = os.geteuid()
AttributeError: module 'os' has no attribute 'geteuid'

Python 3 Upgrade script fails

I backed up my Octoprint with the backup menu item.
Flashed the new version, 0.17. Went through the rest of the setup as required for Octoprint.
Ran the update script for python 3, and it fails:
pi@octopi:~ $ curl -L https://raw.githubusercontent.com/cp2004/Octoprint-Upgrade-To-Py3/master/go_back.py --output go_back.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2804 100 2804 0 0 21082 0 --:--:-- --:--:-- --:--:-- 21242
pi@octopi:~ $ python3 go_back.py
OctoPrint upgrade to Python 3: go_back.py (v1.1)
This script will move your old installation back (Just in case!)
Only use it if you have used the upgrade script and it failed
Warning: There have been reports of this script failing, if it fails for you please report it to me as soon as possible. Thanks!
Press [enter] to continue, or ctrl-c to stop

Detected OctoPi installation
mv: cannot stat '/home/pi/oprint.bak': No such file or directory
ERROR: failed to restore backup
Please try manually
Exiting
pi@octopi:~ $

[Bug] OctoPrint-PrettyGCode plugin wasn't reinstalled after the migration

Describe the bug
Upgrade went fine aside from losing this one plugin. It does support Python 3 and reinstalling manually has gone fine.

Script output
Sorry I've lost the output, but it was the latest version yesterday.

Script version
Sorry I've lost the output, but it was the latest version yesterday.

OctoPrint Version
OctoPrint 1.4.2

Relevant plugins that may have caused errors
OctoPrint-PrettyGCode

The only errors in the output were the benign ones from Octolapse in #6.

Additional information
https://plugins.octoprint.org/plugins/PrettyGCode/

Trouble when running the install script

Hi, this is the message I got.

Detecting system info...
OctoPi version: 0.16.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
Traceback (most recent call last):
File "upgrade.py", line 554, in
plugin_keys = read_plugins_from_backup(backup_location)
File "upgrade.py", line 370, in read_plugins_from_backup
plugin_list = json.load(plugins)
File "/usr/lib/python3.5/json/init.py", line 268, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib/python3.5/json/init.py", line 312, in loads
s.class.name))
TypeError: the JSON object must be str, not 'bytes'

Any help would be great!
Thanks,
David

[Bug] upgrade.py script fails while reading OctoPrint version

Describe the bug
I tried the upgrade on raspbian 9, but it didn't have python3. So I upgraded to raspbian 10. Now the script runs, but fails after I enter all the paths.

Script output
Please paste the output of the script in the box below:

panther@raspistripes:~ $ python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.1.8)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint (1.4.2) and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
Please provide the path to your virtual environment and the config directory of OctoPrint
On OctoPi, this would be `/home/pi/oprint` (venv), `/home/pi/.octoprint` (config)
and service commands commands `sudo service octoprint stop/start`
Path: /home/panther/OctoPrint/venv
Path valid
Config directory: /home/panther/.octoprint
Config directory valid

To do the install, we need the service stop and start commands. (Leave blank if you don't have a service set up)
Stop command: service octoprint stop
Start command: service octoprint start
Getting OctoPrint version...
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 163, in _run_module_as_main
    mod_name, _Error)
  File "/usr/lib/python2.7/runpy.py", line 111, in _get_module_details
    __import__(mod_name)  # Do not catch exceptions initializing package
  File "/home/panther/OctoPrint/venv/local/lib/python2.7/site-packages/octoprint/__init__.py", line 7, in <module>
    import logging as log
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref, collections
  File "/usr/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Failed to find OctoPrint install
If you are not on OctoPi, please check you entered the correct path to your virtual environment

Script version
v2.1.8

OctoPrint Version
OctoPrint 1.4.2

Relevant plugins that may have caused errors
If you're having trouble with a particular part, please include your installed plugins

Additional information
Screenshots, links to docs, etc.

UTF-8 decode error installing Python3-dev

Describe the bug
Running the script, even multiple times ends with the same error.

Script output
Please paste the output of the script in the box below:

sudo python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.0.3)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint (1.4.2) and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
Traceback (most recent call last):
  File "upgrade.py", line 555, in <module>
    plugin_keys = read_plugins_from_backup(backup_location)
  File "upgrade.py", line 362, in read_plugins_from_backup
    with zipfile.ZipFile(backup_path, 'r') as zip_ref:
  File "/usr/lib/python3.7/zipfile.py", line 1204, in __init__
    self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/.octoprint/data/backup/octoprint-backup-20200910-152705.zip'

Script version
Printed at the very top of the script

OctoPrint Version
OctoPrint 1.4.2 Python 2.7.16 OctoPi 0.17.0

blocked because octopi version is too old

I have upgraded the system using the standard apt-get commands to latest version but your script is checking for a octopi version file I believe any way around this?

Exception in exception with backup FileNotFound handling

Here's what happened:

rocket@taz6:~ $ curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 154 100 154 0 0 203 0 --:--:-- --:--:-- --:--:-- 203
100 23760 100 23760 0 0 20589 0 0:00:01 0:00:01 --:--:-- 150k
rocket@taz6:~ $ python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.1.1)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint (1.4.2) and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
Failed to read created backup & plugins list
Traceback (most recent call last):
File "upgrade.py", line 386, in read_plugins_from_backup
with zipfile.ZipFile(backup_path, 'r') as zip_ref:
File "/usr/lib/python3.7/zipfile.py", line 1204, in init
self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/.octoprint/data/backup/octoprint-backup-20200914-210648.zip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "upgrade.py", line 591, in
plugin_keys = read_plugins_from_backup(backup_location)
File "upgrade.py", line 398, in read_plugins_from_backup
print_c("If you ran this script using root (sudo), please make sure you don't, and run using python3 upgrade.py, as per the guide.")
TypeError: print_c() missing 1 required positional argument: 'color'
rocket@taz6:~ $

Upgrade script for Octoprint with Python3 fail

OS : Debian 8.3.0-6 "Jessie"
Kernel : Linux srvlinux 4.19.0-17-amd64 #1 SMP Debian 4.19.194-1 (2021-06-10) x86_64 GNU/Linux [10.10]
PC : Intel NUC 10i3FNK

SHELL :

root@srvlinux:/home/octoprint# su - octoprint -c "python3 upgrade.py"
OctoPrint Upgrade to Py 3 (v2.1.13)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
Please provide the path to your virtual environment and the config directory of OctoPrint
On OctoPi, this would be /home/pi/oprint (venv), /home/pi/.octoprint (config)
and service commands commands sudo service octoprint stop/start
Path: /opt/OctoPrint/venv
Path valid
Config directory: /opt/OctoPrint/.octoprint
Config directory valid

To do the install, we need the service stop and start commands. (Leave blank if you don't have a service set up)
Stop command: sudo service octoprint stop
Start command: sudo service octoprint start
Getting OctoPrint version...
OctoPrint version: 1.6.1
Reading installed plugins...
2021-06-20 15:25:42,552 - octolapse.init - INFO - Release mode detected.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/logging/init.py", line 1676, in shutdown
h.close()
File "/opt/OctoPrint/venv/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 31, in close
self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/logging/init.py", line 1676, in shutdown
h.close()
File "/opt/OctoPrint/venv/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 31, in close
self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'
Failed to read created backup & plugins list
If you ran this script using root (sudo), please make sure you don't, and run using python3 upgrade.py, as per the guide.
The other reason this may happen is if you are not running as the same user OctoPrint is installed as/runs under.
Error: Could not read backup

Refactor checks into 'pre-flight' suite

Current checks:

  • Python version (3.6+)
  • Linux
  • OctoPi > 0.16 - is this covered by Py3.6?
  • no sudo
  • OctoPrint > 1.4.0
  • Virtual env is not Py3.6

Checks to add

  • Requests dependency (confirm if you don't want to install it

Could probably be refactored into a list of checks, to make the output easier to understand. And put them all at the beginning, so it is obvious if there might be problems.

Requests preinstalled on most systems, but maybe not. Add a check before running the script, that the user should install if it is not already.

#29

[Bug] Can't set locale & Broken pipe error

Describe the bug

Script version
OctoPrint Upgrade to Py 3 (v2.2.1)

OctoPrint Version
OctoPrint 1.7.0

Relevant plugins that may have caused errors

  • HeaterTimeout

Script output

Checking system info...
Detected OctoPi version 0.17.0
Checking OctoPrint version...
OctoPrint version: 1.7.0
Reading installed plugins...

Plugins installed

  • HeaterTimeout
    If you think there is something missing from here, please check the list of plugins in OctoPrint
    Press [enter] to continue or ctrl-c to quit

Updating package list...

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for pi:

Checking package list for python3-dev
Installing python3-dev...
apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "en_US.UTF-8",
LC_MONETARY = "en_US.UTF-8",
LC_CTYPE = "C.UTF-8",
LC_ADDRESS = "en_US.UTF-8",
LC_TELEPHONE = "en_US.UTF-8",
LC_NAME = "en_US.UTF-8",
LC_MEASUREMENT = "en_US.UTF-8",
LC_IDENTIFICATION = "en_US.UTF-8",
LC_NUMERIC = "en_US.UTF-8",
LC_PAPER = "en_US.UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
Traceback (most recent call last):
File "upgrade.py", line 679, in
run_apt_install("python3-dev", backup_location)
File "upgrade.py", line 177, in run_apt_install
output, poll = run_sys_command(["sudo", "apt-get", "install", package, "-y"], sudo=True)
File "upgrade.py", line 107, in run_sys_command
output_line = process.stdout.readline().decode('utf-8', errors="replace")
KeyboardInterrupt
pi@octopi2:~ $ E: Setting in Stop via TCSAFLUSH for stdin failed! - tcsetattr (5: Input/output error)
E: Write error - write (32: Broken pipe)
E: Setting in Stop via TCSAFLUSH for stdin failed! - tcsetattr (5: Input/output error)
W: Operation was interrupted before it could finish

Additional information
not sure why it failed. Closing the SSH terminal and running it again seems to have gotten further. This is the new output on the second attempt:

Script output (second attempt)

pi@octopi2:~ $ python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.2.1)

This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Checking system info...
Detected OctoPi version 0.17.0
Checking OctoPrint version...
OctoPrint version: 1.7.0
Reading installed plugins...

Plugins installed

  • HeaterTimeout
    If you think there is something missing from here, please check the list of plugins in OctoPrint
    Press [enter] to continue or ctrl-c to quit

Updating package list...
[sudo] password for pi:
Checking package list for python3-dev
python3-dev is already installed
Checking package list for python3-venv
Installing python3-venv...
apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "en_US.UTF-8",
LC_MONETARY = "en_US.UTF-8",
LC_CTYPE = "C.UTF-8",
LC_ADDRESS = "en_US.UTF-8",
LC_TELEPHONE = "en_US.UTF-8",
LC_NAME = "en_US.UTF-8",
LC_MEASUREMENT = "en_US.UTF-8",
LC_IDENTIFICATION = "en_US.UTF-8",
LC_NUMERIC = "en_US.UTF-8",
LC_PAPER = "en_US.UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
Successfully installed python3-dev
Creating new Python 3 environment...
Successfully created Python 3 environment at /home/pi/oprint
Installing build dependencies...
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored

Installing OctoPrint... (This may take a while - Do not cancel!)
Collecting required packages
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Installing collected packages
OctoPrint successfully installed!

Downloading OctoPrint's plugin repo

Installing HeaterTimeout
Collecting required packages
Installing collected packages
Plugin HeaterTimeout successfully installed

Cleaning up...
Finished! OctoPrint should be ready to go
Once you have verified the install works, you can safely remove the folder /home/pi/oprint.bak
If you want to go back (If it doesn't work) to Python 2 download the file at:
https://raw.githubusercontent.com/cp2004/Octoprint-Upgrade-To-Py3/master/go_back.py
pi@octopi2:~ $

[Bug]

upgrade won't run properly on non privileged account.

It is not a good idea to run things like octopi on privileged accounts (accounts with root or sudo access). I turn off the privileges of the 'pi' account since it is a typical attack vector used by hackers. Thus if I try to run your script as root, it says it won't run. But if I try to run it as the pi user, it says it wants sudo access. This is bad design. Meanwhile, if I try to run it as my own user, it can't write the pi user directories (again, privilege separation means I 'should not' be able to write pi/server/octoprint directories with a user account without using sudo first)
You need to re-think how you go about that and possibly add a parameter or conditionals to specify the octopi user and/or check that it's installing in a way that can access that user's files as well as do any sudo access you need.

Error: Failed to create Python 3 venv

Could not create new venv Cleaning up...
Fatal Error: Exiting

Script output
Please paste the complete output of the script in the box below:

OctoPrint Upgrade to Py 3 (v2.1.15)                                                                                                                                                                                                                 
Hello!                                                                                                                    
This script will move your existing OctoPrint configuration from Python 2 to Python 3                                     
This script requires an internet connection and it will disrupt any ongoing print jobs.                                                                                                                                                             
It will install the latest version of OctoPrint and all plugins.                                                          
No configuration or other files will be overwritten                                                                                                                                                                                                 
Press [enter] to continue or ctrl-c to quit                                                                                                                                                                                                         
Detecting system info...                                                                                                  
OctoPi version: 0.17.0                                                                                                    
Getting OctoPrint version...                                                                                              
OctoPrint version: 1.6.1                                                                                                  
Reading installed plugins...                                                                                                                                                                                                                        
Plugins installed                                                                                                         
- Filament Sensor Reloaded                                                                                                
- OctoPrint-IFTTT                                                                                                         
- Filament Scale                                                                                                          
- Enclosure Plugin                                                                                                       
- GPIO Shutdown                                                                                                           
If you think there is something missing from here, please check the list of plugins in Octoprint                          
Press [enter] to continue or ctrl-c to quit                                                                                                                                                                                                         
Checking package list for python3-dev                                                                                     
python3-dev not installed, proceeding to install                                                                          
Root access is required to install python3-dev, please fill in the password prompt if shown                               
Updating package list...                                                                                                  
[sudo] password for pi:                                                                                                   
Installing python3-dev...                                                                                                 
Successfully installed python3-dev                                                                                        
Creating new Python 3 environment...                                                                                      
ERROR: Failed to create Python 3 venv                                                                                     
Could not create new venv                                                                                                                                                                                                                           
Cleaning up...                                                                                                            
Fatal Error: Exiting                                                                                                      
pi@octopi:~ $

Script version
You can find this printed in the first line of the script

OctoPrint Version
OctoPrint 1.().()

Relevant plugins that may have caused errors
If you're having trouble with a particular part, please include your installed plugins

Additional information
Screenshots, links to docs, etc.

Script it doesn't work here

Describe the bug
Unfortunately I'm not using OctoPi but it's still a Buster.
The error is in the output.

Script output
Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
Please provide the path to your virtual environment and the config directory of OctoPrint
On OctoPi, this would be /home/pi/oprint (venv), /home/pi/.octoprint (config)
and service commands commands sudo service octoprint stop/start
Path: /home/pi/OctoPrint
Invalid venv path, please try again
Path: /home/pi/OctoPrint/venv
Path valid
Config directory: /home/pi/.octoprint
Config directory valid

To do the install, we need the service stop and start commands. (Leave blank if you don't have a service set up)
Stop command: sudo service octoprint stop
Start command: sudo service octoprint start
Getting OctoPrint version...
OctoPrint version: 1.6.1
Reading installed plugins...
2021-06-26 19:27:55,231 - octolapse.init - INFO - Release mode detected.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/logging/init.py", line 1669, in shutdown
h.close()
File "/home/pi/OctoPrint/venv/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 31, in close
self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/logging/init.py", line 1669, in shutdown
h.close()
File "/home/pi/OctoPrint/venv/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 31, in close
self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'

Plugins installed

  • DisplayLayerProgress Plugin
  • DryRun Plugin
  • Firmware Updater
  • PrettyGCode
  • Fullscreen Plugin
  • PSU Control - RPi.GPIO
  • Custom Control Editor
  • FileManager
  • Autoscroll
  • OctoKlipper
  • Fan Speed Control
  • InlineConfirm
  • System Command Editor
  • Detailed Progress
  • Dashboard
  • PSU Control
  • Arc-Welder
  • Octolapse
    If there is an error above related to OctoLapse, please ignore, it makes no difference to operation :)
    If you think there is something missing from here, please check the list of plugins in Octoprint
    Press [enter] to continue or ctrl-c to quit

Checking package list for python3-dev
Successfully checked python3-dev
Creating new Python 3 environment...
ERROR: Failed to create Python 3 venv
Could not create new venv

Cleaning up...
Fatal Error: Exiting
pi@Raspberry1:~ $

Script version
The latest of today.

OctoPrint Version
OctoPrint 1.6.1

Relevant plugins that may have caused errors
I don't think plugins are causing any problems.

Additional information
None.

[Bug] Script Unable to parse Python version string.

I post it here cause it said so:

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?
Please try again

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.