I installed python3 and pip3 on my OpenWrt build, but don't have enough space for other python packages. So, I installed my custom packages via pip3 -t /mnt/sda1/.config/python3.
However, I can't call any of the applications since the python applications are not found in the normal directory.
Where can I set the PYTHONPATH to /mnt/sda1/.config/python3 in OpenWrt? Should I add export PYTHONPATH="${PYTHONPATH}:/mnt/sda1/.config/python3 to /etc/profile?
Sure. You could also add to the path within your python app before the imports. Finally, you could also soft link them in /usr/lib/python/site-packages/x so they "are" in PYTHONPATH.
One thing to keep in mind is that all the actions that are part of setup.py for these packages and were not just deploying the package have not happened (copying binaries...).
Thanks. I added it to /etc/profile and reloaded bash but it doesn't work. The packages I installed with -t show up via pip3 list. However, they still don't run via the command line with "mnamer" or "python3 mnamer" python3: can't open file 'mnamer': [Errno 2] No such file or directory
I think I am missing something pretty basic here but not sure what. When you say copying binaries do I need to do that manually?
Just to be clear, if you are using bash (and not ash) and not using a --login option, you most likely need to have the PYTHONPATH in .bashrc or similar.
Also, to use mnamer directly, there needs to be the entrypoint in your PATH (which is the part where I wasn't sure about pip3 behaviour on -t as I haven't used it before)
Can you run a couple of commands just to give us a feel for your setup?
echo $PYTHONPATH
pip3 show mnamer
find / -name mnamer
The first one to see that PYTHONPATH is in fact set. The second one to check what pip3 did with the package and the third one to see if we can find the mnamer entrypoint.
For the last one, /mnt/sda1/config/ exists because I tried installing it to a non-hidden directory but it didn't work so I went back to the .config directory. I uninstalled the packages with pip3 but it didn't seem to remove those entry points.
thanks.
So, for you to call directly mnamer, it needs to be in your PATH.
You can first try directly with the full path to see if it works.
Does that work if you run it?
/mnt/sda1/.config/python3/bin/mnamer
Then the next thing is that python complained it couldn't find mnamer but that's because it was looking for that file locally when you run the command.
To see if it's in your PYTHONPATH, you can try the following:
python3
>>> from mnamer.__main__ import main
>>> main()
mnamer [preferences] [directives] target [targets ...]
But I'd say, you should just focus on being able to run the mnamer script from the bin/ directory (and forget about the python3 way, unless you want to extend the package with your own script, in that case, use the imports the way I did in that last example)
Great. Yes, calling the full path works, thank you!
I hear you on the script and will use that in extending the package for my own script.
But first, how do I make sure that I can call every bin from the command line? Do I need to change PYTHONPATH to PYTHONPATH="${PYTHONPATH}:/mnt/sda1/.config/python3/bin?
Then what I meant was just to add that bin folder to the normal PATH environment variable which is used to find executable files. You can do that in your profile as well for example.
Back again. Something is really screwed up. I can create a new thread if needed, but basically I restarted the router and came back to mnamer not working.
I uninstalled all the python packages, reinstalled, and ran the following commands. mnamer isn't even showing up as installed.
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'
pip3 list
Package Version
---------- -------
pip 20.1.1
setuptools 41.2.0