Octoprint on a Openwrt

Hello
Can't run octoprint.
I built the image of an openwrt with python and pip and flashing it in a router
Install OctoPrint

# pip install octoprint

the installation goes without fail
Execute it

# octoprint serve
2019-11-28 20:08:32,981 - octoprint.startup - INFO - ******************************************************************************
2019-11-28 20:08:32,995 - octoprint.startup - INFO - Starting OctoPrint 1.3.12
2019-11-28 20:08:32,999 - octoprint.startup - INFO - ******************************************************************************
2019-11-28 20:08:33,367 - octoprint.plugin.core - INFO - Loading plugins from /usr/lib/python2.7/site-packages/octoprint/plugins, /root/.octoprint/plugins and installed plugin packages...
2019-11-28 20:08:34,403 - octoprint.plugin.core - INFO - Found 1 plugin(s) providing 0 mixin implementations, 0 hook handlers
2019-11-28 20:08:36,466 - octoprint.startup - CRITICAL - Could not initialize environment detector: cannot import name _psutil_linux
2019-11-28 20:08:36,478 - octoprint.startup - CRITICAL - There was a fatal error starting up OctoPrint.
Could not initialize environment detector: cannot import name _psutil_linux
There was a fatal error starting up OctoPrint

List of installed packages, psutil installed.

# pip list
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support                        
Package          Version    
---------------- -----------
argh             0.26.2     
awesome-slugify  1.6.5      
Babel            2.7.0      
backports-abc    0.5        
blinker          1.4        
cachelib         0.1        
certifi          2019.11.28 
chainmap         1.0.3      
chardet          3.0.4      
Click            7.0        
emoji            0.5.4      
feedparser       5.2.1      
filetype         1.0.5      
Flask            0.10.1     
Flask-Assets     0.12       
Flask-Babel      0.12.2     
Flask-Login      0.2.11     
Flask-Principal  0.4.0      
frozendict       1.2        
future           0.17.1     
futures          3.2.0      
idna             2.8        
itsdangerous     1.1.0      
Jinja2           2.8.1      
Markdown         3.0.1      
MarkupSafe       1.1.1      
monotonic        1.5        
netaddr          0.7.19     
netifaces        0.10.9     
OctoPrint        1.3.12     
pathtools        0.1.2      
pip              19.2.3     
pkginfo          1.5.0.1    
psutil           5.6.7      
pyasn1           0.4.8      
pylru            1.2.0      
pyserial         3.4        
pytz             2019.3     
PyYAML           5.1.2      
regex            2019.11.1  
requests         2.22.0     
rsa              4.0        
sarge            0.1.5.post0
scandir          1.10.0     
semantic-version 2.6.0      
sentry-sdk       0.7.7      
setuptools       41.2.0     
singledispatch   3.4.0.3    
six              1.13.0     
tornado          4.5.3      
typing           3.7.4.1    
Unidecode        0.4.21     
urllib3          1.25.7     
watchdog         0.9.0      
webassets        0.12.1     
websocket-client 0.56.0     
Werkzeug         0.15.6     
wrapt            1.11.2     
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@OpenWrt:~#

Unfortunately I do not know python and cannot fix this problem. How to run it?

IMHO a router is one of the worst platforms you can choose to run octoprint.
Even a pi zero is more suitable.

Sounds like you might want to activate the virtual environment and then install this.

What I see:

# pip list            # The pound sign prompt should only be seen when you're root

What I should be seeing:

(oprint) $ pip freeze

In other words, you should be logged in as a non-root user having activated a virtual environment with Python 2.7 in it.

It's possible that it would run like you're trying to do it but it might end up running as the root user and that would give too much rights to OctoPrint itself and the plugins you run. It's probably a bad idea.

I have partly dealt with this question
I wanted to use openwrt as a simpler and faster alternative to raspbian. But everything is very difficult for me. Many python packages require to build shared libraries. I'm not always correct make on the host system.
here is the list
Package psutil builds the _psutil_linux.so and _psutil_posix.so
regex - _regex.so (this build is uncorrect)

2019-11-28 22:44:28,697 - octoprint.cli.server - ERROR - Uncaught exception
Traceback (most recent call last):
  File "/usr/bin/octoprint", line 11, in <module>
    load_entry_point('OctoPrint==1.3.12', 'console_scripts', 'octoprint')()
  File "/usr/lib/python2.7/site-packages/octoprint/__init__.py", line 609, in main
    octo(args=args, prog_name="octoprint", auto_envvar_prefix="OCTOPRINT")
  File "/usr/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/octoprint/cli/server.py", line 206, in serve_command
    ignore_blacklist)
  File "/usr/lib/python2.7/site-packages/octoprint/cli/server.py", line 105, in run_server
    from octoprint.server import Server
  File "/usr/lib/python2.7/site-packages/octoprint/server/__init__.py", line 66, in <module>
    from octoprint.printer.profile import PrinterProfileManager
  File "/usr/lib/python2.7/site-packages/octoprint/printer/__init__.py", line 28, in <module>
    from octoprint.filemanager import FileDestinations
  File "/usr/lib/python2.7/site-packages/octoprint/filemanager/__init__.py", line 18, in <module>
    from .storage import LocalFileStorage
  File "/usr/lib/python2.7/site-packages/octoprint/filemanager/storage.py", line 27, in <module>
    from slugify import Slugify
  File "/usr/lib/python2.7/site-packages/slugify/__init__.py", line 2, in <module>
    from slugify.main import Slugify, UniqueSlugify
  File "/usr/lib/python2.7/site-packages/slugify/main.py", line 6, in <module>
    import regex as re
  File "/usr/lib/python2.7/site-packages/regex/__init__.py", line 1, in <module>
    from .regex import *
  File "/usr/lib/python2.7/site-packages/regex/regex.py", line 391, in <module>
    import _regex_core
  File "/usr/lib/python2.7/site-packages/regex/_regex_core.py", line 21, in <module>
    import _regex
ImportError: Error relocating /usr/lib/python2.7/site-packages/regex/_regex.so: PyUnicodeUCS4_Join: symbol not found

and watchdog pakage is building his library, I haven't built it yet

Anything with a .so ending is something that is built. It's a binary object file. Like I said, I'm familiar with an install to the virtual environment rather than things installed at the global level.

mmfroebus_01636196

You can run openwrt on a Ryzen ...
It's just a distro. -> Software ...

Well yes. But why should you?
If you're building your own router you would use something like pfsense, opnsense or ipfire.
Also it's very unusal to keep your servers next to your 3D printer (at least in my mind) - so I figured he's using a something like a tp link router.
Then he said he's using it as an faster alternative to raspbian - which is an OS for a single board computer (like a tp link router). That confirmed my thought for me.
Of course you also could use raspbian on a pc - but again - why should you?

I want to use my old raspberrypi. Raspbian works very slowly in it. I thought if there was a python, that's not a problem. I was wrong, it has difficulties ...

That's ok :slight_smile:
I'm the last person who would stop anyone from tinkering :smiley:

I was just explaining my train of thoughts to @danielkrah :slight_smile:

Maybe you should search for other lightweight distros


Here a bit older list of raspberry compatible distros

@PrintedWeezl
some vpn clients need a huge singlecore performance.
but yeah on a raspberry it don't makes sense performance wise.

And on a bigger machine running it in a VM is maybe the better choice ...

I've worked with Yocto. It can be about as lean as you want to make it.

psutil and regex built, continue to run octoprint. Now he stopped to build netifaces....

# octoprint serve
2019-11-29 21:37:09,971 - octoprint.startup - INFO - ******************************************************************************
2019-11-29 21:37:09,985 - octoprint.startup - INFO - Starting OctoPrint 1.3.12
2019-11-29 21:37:09,989 - octoprint.startup - INFO - ******************************************************************************
2019-11-29 21:37:10,382 - octoprint.plugin.core - INFO - Loading plugins from /usr/lib/python2.7/site-packages/octoprint/plugins, /root/.octoprint/plugins and installed plugin packages...
2019-11-29 21:37:11,471 - octoprint.plugin.core - INFO - Found 1 plugin(s) providing 0 mixin implementations, 0 hook handlers
2019-11-29 21:37:28,049 - octoprint.cli.server - ERROR - Uncaught exception
Traceback (most recent call last):
  File "/usr/bin/octoprint", line 11, in <module>
    load_entry_point('OctoPrint==1.3.12', 'console_scripts', 'octoprint')()
  File "/usr/lib/python2.7/site-packages/octoprint/__init__.py", line 609, in main
    octo(args=args, prog_name="octoprint", auto_envvar_prefix="OCTOPRINT")
  File "/usr/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/octoprint/cli/server.py", line 206, in serve_command
    ignore_blacklist)
  File "/usr/lib/python2.7/site-packages/octoprint/cli/server.py", line 105, in run_server
    from octoprint.server import Server
  File "/usr/lib/python2.7/site-packages/octoprint/server/__init__.py", line 75, in <module>
    import octoprint.util.net
  File "/usr/lib/python2.7/site-packages/octoprint/util/net.py", line 10, in <module>
    import netifaces
ImportError: No module named netifaces

Activate the virtual environment then...

pip install netifaces

As I wrote above, everything is difficult. For the netifaces module, it is necessary to build netifaces.so ....

pip (and other programs like npm, yarn and brew) are package managers. It's their job to compile/build what you just asked for. In some cases they might find something ready to go and apply that for you. Otherwise they'll often make that happen.

What I guess that I'm saying is that you've chosen a platform other than the one described here for the OctoPi image. So then you get the responsibility of making that work. The usual expected behavior is for you to read the error, search the Internet for that error, see what's missing and to fill in the gaps. If you need to install netifaces in this case, install netifaces and then continue the process.

Ok, I know what to do ... I didn't just think that a python was so tightly bound to a code on a с
Maybe without gсс nothing can be installed...

Yeah, you might need all kind of things, like setuptools, etc.

gcc comes with the standard Raspbian install. These "minimized" Linux installs are made small because they're missing many things. They assume that you're good at then building them up to the level you need.