Ubuntu 18.04/20.04安装python3-serial后miniterm.py未加入PATH的问题求助
Hey there, sorry you're stuck with this miniterm.py PATH issue—this is a pretty common quirk with how pyserial is packaged on Ubuntu, so let's work through it step by step:
First, track down where miniterm.py is actually installed
The apt packagepython3-serialdoesn't put miniterm.py directly in/usr/binor/usr/local/binlike you might expect. It's stored in Python's site-packages directory instead. Run this command to locate it quickly (it skips permission error messages to keep output clean):sudo find / -name miniterm.py 2>/dev/nullFor the apt-installed version, you'll probably find it at
/usr/lib/python3/dist-packages/serial/tools/miniterm.py. If you used pip in a virtual environment, it'll be inside that env'ssite-packagesfolder.Two simple ways to make it accessible without typing the full path
Use Python's module execution (most reliable)
You don't need the file in your PATH at all—just run it directly via the pyserial module. This works no matter where the package is installed (system-wide or in a virtual env):python3 -m serial.tools.minitermThis is actually the recommended way to run many Python command-line tools, since it bypasses PATH issues entirely.
Create a symbolic link to a PATH directory
If you prefer typing justminiterm.py, make a soft link to a folder that's already in your PATH (like~/.local/bin, which doesn't require sudo privileges):ln -s /usr/lib/python3/dist-packages/serial/tools/miniterm.py ~/.local/bin/miniterm.pyDouble-check
~/.local/binis in your PATH withecho $PATH. If it's missing, add this line to your~/.bashrcfile:export PATH="$HOME/.local/bin:$PATH"Then reload your shell settings with
source ~/.bashrc.
If miniterm.py is nowhere to be found
Your installation might be corrupted. Try re-installing the apt package from scratch:sudo apt purge python3-serial && sudo apt autoremove && sudo apt install -y python3-serialFor virtual environments, make sure you activate the env first, then re-install pyserial:
source your-env/bin/activate pip uninstall pyserial pip install pyserialRun the
findcommand again after this to locate the file.
备注:内容来源于stack exchange,提问作者Bogdan Prădatu

