Upgrade your OctoPrint install to Python 3!

Where can I find the venv path the script is asking for?

This is where you installed OctoPrint. You would have set that when you set it up. It is often something like /home/pi/OctoPrint/venv, which is recommended in the RPi install path. But we can't really help if you don't know where you put it.

If you are using OctoPi then it should detect it automatically.

I am executing the Python upgrade and I encounter errors. After the upgrade completes and octoprint is restarted it exits. I don't see any errors/reason in the logs. When I manually execute 'octoprint serve', this command exits with Illegal Instruction. The last thing I see in the octoprint log is:

2022-01-02 10:28:27,864 - octoprint.plugin.core - INFO - Found 19 plugin(s) providing 19 mixin implementations, 43 hook handlers

Hardware: Raspberry Pi Model B Rev 2
OS: Linux raspberrypi 5.10.63+ #1496 Wed Dec 1 15:57:05 GMT 2021 armv6l GNU/Linux
Octoprint Version: 1.7.2
Python Version: 3.7.3

Looking for recommendations on how to proceed. Thanks!

That's interesting - illegal instruction is something we've sometimes seen on a corrupted install. It could be that something in the upgrade went wrong, in which case maybe try again - the backup of the old environment is stored as well.

Run the following switch back the environments (assuming this is an OctoPi install):

cd ~
mv oprint oprint-failed
mv oprint.bak oprint
sudo service octoprint

Remove pip's cache:

rm -rf ~/.cache/pip

Then try the update again.

Reattempted thpgrade per the steps provided. I saw this error in the upgrade log:

Reading installed plugins...
Exception in thread zeroconf-Reaper (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
  File "/home/pi/virtualenv/OctoPrint/local/lib/python2.7/site-packages/octoprint/vendor/zeroconf.py", line 1234, in run
  File "/home/pi/virtualenv/OctoPrint/local/lib/python2.7/site-packages/octoprint/vendor/zeroconf.py", line 1823, in wait
  File "/usr/lib/python2.7/threading.py", line 289, in __exit__
  File "/usr/lib/python2.7/threading.py", line 216, in __exit__
  File "/usr/lib/python2.7/threading.py", line 203, in release
<type 'exceptions.TypeError'>: 'NoneType' object is not callable

The upgrade script is continued but failed again in the same way. Anything else I should try?

For what it is worth, I attempted a manual install into a new Python3 virtual environment and saw the same behavior of the Illegal Instruction when starting up.

It seems like something in the Python environment has broken itself - I'm not sure how to fix it. It might be easier for you to take a backup and install OctoPi 0.18, which comes with Python 3 by default, as described in the main FAQ post: Upgrading your OctoPrint install to Python 3

I looked at the logs more today and noticed this in the logs from the attempt of manually running the upgrade steps. Could these warnings cause the "Invalid Instruction" to be encountered?

2022-01-03 09:16:27,092 - octoprint.plugin.core - WARNING - Invalid version requirement >=0.1.1,<=0.2.8 for blacklist entry GcodeEditor, ignoring
2022-01-03 09:16:27,097 - octoprint.plugin.core - WARNING - Invalid version requirement >=0.1.0,<=0.1.1 for blacklist entry gcodeleveling, ignoring

No, that was a mistake on our part in OctoPrint 1.7.x, it's fixed for 1.8.x (whenever that is released). I think that warning will be showing up in everyone's log files...

Illegal instruction is a lot more low-level. It's saying something that Python asked the computer to do was invalid - most Python code never gets that far. It is more common to happen if you try and run code not compiled for your machine, on it. Like running x86 code on a RPi (ARMv7), it will fail.

Yes, I was wondering if the install pulled in an incorrect architecture of a binary. I am using older hardware.

Thank you for mentioning this... I had started mucking through all the update stuff, then saw this... saved me a bunch of time and head-banging.

You're most welcome!

I resolved the issue I described above by downloading Python 3.10.1, installing dependencies, and compiling the source. I then installed OctoPrint into a new Python3 virtual environment and everything seems to work ask expected.

Hi, I had the same problem. It has turned out to be a problem with psutil 5.9. I have downgraded it to 5.8 and everything seems to work fine now.

Steps:

  1. Run the python 2->3 upgrade script: python3 upgrade.py
  2. Activate the new environment: source /home/pi/oprint/bin/activate
  3. Downgrade psutil: pip install psutil==5.8
  4. Restart Octoprint: sudo systemctl restart octoprint
1 Like

I am running Mac OS Catalina 10.15.7 on a Mac 27 inch late 2012.

I have tried many times to update to Python 3.

Most methods I have tried require Xcode which is not available for the Catalina.

I have tried Home Brew installation as well but it also fails.

I have also tried a Mac Min M1 but is also will not install.

If anyone has any ideas, I would appreciate them.

Regards

John

I'm getting the error "E: The repository 'Index of /ubuntu wily Release' does not have a Release file."

I'm running it in /home/pi/OctoPrint, is that the correct directory? Currently on OctoPrint version 1.7.3

Ubuntu Wily (15.10) (which it looks like you might be using there, from the output) was end-of-life in 2016, and it is complaining that it can't download it's package list - Ubuntu aren't going to provide apt repositories for unsupported OSes . This OS is too old, you'll need to upgrade it. If you aren't running that old OS, then your apt sources are not configured correctly.

HI
I have the following conf :

Raspberry Pi Zero W Rev 1.1
octopi_version: 0.17.0
Octoprint 1.13.12

I did not succed to use the upgrade.py script.
Initialy I had only python 2.7
I try to install python 3.7 but I get the following message

Please upgrade to an OctoPrint version >= 1.4.0 for Python 3 compatibility

I try the following command

pip install octoprint==1.4.0

It seem's to work (no warning or error)
But with a :

sudo service octoprint start

My octoprint version is still 1.13.12

How can I upograde without reflasing the SD card?

run this after running the command source ~/oprint/bin/activate

Wonderfull you are the boss :slight_smile:
Thanks, now just have to pass to python 3...