question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleNotFoundError: No module named 'encodings'

See original GitHub issue

Description Mariner can’t be started on DietPi

Reproduction Steps Steps to reproduce the behavior:

  1. Install DietPi on SD card, boot and do minimal setup to get a running system.
  2. Follow setup instructions to install mariner package from PPA
  3. (optional) Install dbus to make systemd behave properly

Expected Behavior Mariner starts, preferably from the systemd unit, but manual start via sudo -u mariner mariner is acceptable.

Screenshots / Logs

dietpi@marsbox:~$ sudo -u mariner mariner
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0xb6fc6a00 (most recent call first):
Aborted

Details:

  • Mariner Version: 0.2.0-1
  • Printer Model: Elegoo Mars
  • Raspberry Pi Model: RPi Zero W

Additional context Add any other context about the problem here.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
dmpanchcommented, Nov 14, 2021

@jangrewe

I fixed it by copying python 3.9 to the mariner directory, copying some files from python3.7 to python3.9 directory, and editing/relaunching the post-install script. It’s faster than compiling required Python on Zero.

Symlink Python 3.7 to the Python 3.9

cd /opt/venvs/mariner3d/bin
sudo ln -s python3.7 /usr/bin/python3.9

Copy Python 3.9 libs to the mariner: sudo cp -r /usr/lib/python3.9 /opt/venvs/mariner3d/lib/python3.9

Go to the mariner directory and copy some files/dirs from the Python 3.7 to the Python 3.9 directory:

cd /opt/venvs/mariner3d/lib/python3.7
sudo cp no-global-site-packages.txt ../python3.9/no-global-site-packages.txt
sudo cp orig-prefix.txt ../python3.9/orig-prefix.txt
sudo cp site.py ../python3.9/site.py
sudo cp -r site-packages/ ../python3.9/site-packages/

Edit postinstall script adding Python 3.9 version - find the next string and add Python 3.9 version: sudo nano /var/lib/dpkg/info/mariner3d.postinst local pythonX_Y=$(cd “$dh_venv_install_dir/lib” && ls -1d python3.9 | tail -n1)

Run postinstall script: sudo /var/lib/dpkg/info/mariner3d.postinst configure

Now web interface is running but there are another error “Unexpected Printer Response” (I don’t have a connected printer yet, so not sure if this error cannot be due to this fact)

Traceback (most recent call last):
  File "/opt/venvs/mariner3d/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/venvs/mariner3d/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/venvs/mariner3d/lib/python3.9/site-packages/mariner/server/api.py", line 46, in print_status
    selected_file = elegoo_mars.get_selected_file()
  File "/opt/venvs/mariner3d/lib/python3.9/site-packages/mariner/mars.py", line 102, in get_selected_file
    self._extract_response_with_regex("ok '([^']+)'\r\n", data).group(1)
  File "/opt/venvs/mariner3d/lib/python3.9/site-packages/mariner/mars.py", line 39, in _extract_response_with_regex
    raise UnexpectedPrinterResponse(data)
mariner.exceptions.UnexpectedPrinterResponse
1reaction
kane-thornwyrdcommented, Feb 20, 2022

‼️https://github.com/luizribeiro/mariner/issues/481#issuecomment-968325624 is harmful because you are basically mixing two versions of python hoping for the best, maybe it worked, fine, but you may have screwed the installation of any other softwares relying on Python 3.9 you may want to install later.

I’m in the process of writing a comprehensive issue with a sane solution included, maybe using pyenv.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: No module named 'encodings' - python
I was facing this issue "ModuleNotFoundError: No module named 'encodings" after updating to macOS Catalina. I was having multiple versions of Python ...
Read more >
ModuleNotFoundError: No module named 'encodings' in Python
To solve the ModuleNotFoundError: No module named 'encodings' error, make sure, your virtual environment is not glitched by recreating it and ensure Python ......
Read more >
No Module named “Encodings” — A common ... - faun.dev
When you download Python3. · Then, open system properties and navigate to the “Advanced” tab. · Ensure that the Python path for your...
Read more >
ModuleNotFoundError: No module named 'encodings' #516
I keep getting: ModuleNotFoundError: No module named 'encodings' in the unit error logs when trying to add new configuration.
Read more >
No Module named “Encodings” — A ... - FAUN Publication
The Solution! · When you download Python3. · Then, open system properties and navigate to the “Advanced” tab. · Ensure that the Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found