PYTHONPATH and pip3 Custom Package Location on OpenWrt

OK, and another experiment, could you create path without dots, like

/mnt/sda1/pconfig/python3/bin

And:

import imp
imp.find_module('mnamer')

K. Installed mnamer to /mnt/sda1/config/python3. Same problem:

>>> import imp
__main__:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
>>> imp.find_module('mnamer')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/imp.py", line 296, in find_module
ImportError: No module named 'mnamer'
>>>
/mnt/sda1/config/python3/bin# mnamer
Traceback (most recent call last):
  File "/mnt/sda1/config/python3/bin/mnamer", line 6, in <module>
    from mnamer.__main__ import main
ModuleNotFoundError: No module named 'mnamer'

Should I file a bug report? I'm not sure where the bug is though if it's upstream or OpenWrt specific.

OK, sorry, I don't know, what to do.

1 Like

I think there is still confusion between your PATH and your PYTHONPATH.

PYTHONPATH needs to point to where the python module is location (aka where the directory that contains the mnamer python is located). So, you need to remove "/bin" at the end in the PYTHONPATH definition from your /etc/profile

PATH however needs to point where the mnamer executable has been installed by pip which usually is in a directory ending up in "/bin" for binary

1 Like

Ok. I changed /etc/profile and it worked.

export PYTHONPATH=/mnt/sda1/.config/python3/
export PATH=/mnt/sda1/.config/python3/bin:$PATH

I rebooted the router and the changes persisted.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.