Python has many useful modules. Python programmers need useful modules. New devices of Python programmers will also need useful modules too.

Unfortunately, we need to re-install the favourite modules again on the new machines. Copy and paste the installed module directories from the old devices to new devices may cause mysterious bugs, especially with binary modules.

Luckily, if you have installed the modules via pip, then the re-install process of your favourite modules will not take time as much as the time you have spent to find and test these useful modules.

We can simply list them on the old machines, then reinstall them on the new machines easily.

Re-install with the same versions

On the old machines, list them with:

pip3 freeze > python_pkg.txt

It will list the installed modules together with required version numbers, like:

autopep8==1.5.7  
beautifulsoup4==4.9.3

Copy python_pkg.txt to the new machines. And re-install them with:

pip3 install -r python_pkg.txt

Install with the latest version of those modules

Warning: the latest modules can be incompatible with your old app. Your apps may have dependency issues. Don’t do this if you don’t know what you are doing.

Simply strip the ==version numbers and pip3 install them all as usual.

If you didn’t save the module list before the upgrade

Supposed that we accidentally upgrade from python3.9.x to 3.10.0 and found out that all of our installed modules are gone.

On Termux, sometimes we do pkg upgrade -y or simply answer yes without reading which packages are new. This can lead to the above issue.

Luckily the below command can help if the old directory is still there. (Credit: learnt from this answer).

We c still list the old site-packages with:

pip3 freeze --path /data/data/com.termux/files/usr/lib/python3.9/site-packages > python3.9_installed.txt  

Then re-install:

pip3 install -r python3.9_installed.txt

Conclusion

  • So like npm, we need to list the pkg and re-install them.
  • reminder: virtualenv is helpful

Bonus:

Here is a list on my Android phone (on Termux):

Last updated 13 Nov 2021


argon2-cffi==21.1.0
arrow==1.2.0
astroid==2.6.6
attrs==21.2.0
autopep8==1.5.7
backcall==0.2.0
backports.entry-points-selectable==1.1.0
beautifulsoup4==4.10.0
bleach==4.1.0
blinker==1.4
bs4==0.0.1
bz2file==0.98
cachetools==4.2.4
certifi==2021.5.30
cffi==1.14.6
chardet==4.0.0
charset-normalizer==2.0.6
cheroot==8.5.2
ciseau==1.0.1
click==8.0.1
cobble==0.1.3
colorama==0.4.4
commonmark==0.9.1
debugpy==1.5.0
declxml==1.1.3
decorator==5.1.0
defusedxml==0.7.1
distlib==0.3.3
docutils==0.18
EbookLib==0.17.1
eng-to-ipa==0.0.2
entrypoints==0.3
epub==0.5.2
epub-conversion==1.0.15
feedgenerator==2.0.0
filelock==3.3.0
fire==0.4.0
flake8==3.9.2
ftfy==6.0.3
ghp-import==2.0.2
google-api-core==2.1.0
google-api-python-client==2.24.0
google-auth==2.2.1
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.4.6
googleapis-common-protos==1.53.0
googletrans==3.0.0
h11==0.9.0
h2==3.2.0
hpack==3.0.0
hstspreload==2021.10.1
html2text==2020.1.16
html5lib==1.1
httpcore==0.9.1
httplib2==0.20.1
httpx==0.13.3
hyperframe==5.2.0
idna==3.2
importlib-metadata==4.8.1
ipykernel==6.4.1
ipython==7.28.0
ipython-genutils==0.2.0
ipywidgets==7.6.5
isort==5.9.3
jaraco.functools==3.3.0
jedi==0.18.0
Jinja2==3.0.2
joblib==1.0.1
json5==0.9.6
jsonschema==4.0.1
jupyter==1.0.0
jupyter-client==7.0.6
jupyter-console==6.4.0
jupyter-core==4.8.1
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.2
lazy-object-proxy==1.6.0
lxml==4.6.3
mailchecker==4.0.12
mammoth==1.4.17
Markdown==3.3.4
markdownify==0.9.4
MarkupSafe==2.0.1
matplotlib-inline==0.1.3
mccabe==0.6.1
mergedeep==1.3.4
mistune==0.8.4
mkdocs==1.2.3
mkdocs-material==7.3.6
mkdocs-material-extensions==1.0.3
more-itertools==8.10.0
nbclient==0.5.4
nbconvert==6.2.0
nbformat==5.1.3
nest-asyncio==1.5.1
nltk==3.6.3
notebook==6.4.4
numpy==1.21.2
oauth2client==4.1.3
oauthlib==3.1.1
packaging==21.0
pandoc==1.1.0
pandocfilters==1.5.0
parso==0.8.2
pelican==4.7.1
pexpect==4.8.0
phonenumbers==8.12.34
phpserialize==1.3
pickleshare==0.7.5
platformdirs==2.4.0
pluggy==1.0.0
plumbum==1.7.0
ply==3.11
polyglot==16.7.4
prometheus-client==0.11.0
prompt-toolkit==3.0.20
protobuf==3.18.1
ptyprocess==0.7.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.7.0
pycparser==2.20
pydocstyle==6.1.1
pyflakes==2.3.1
pyglossary==4.0.11
Pygments==2.10.0
pylint==2.9.6
pymdown-extensions==9.0
pyparsing==2.4.7
pyrsistent==0.18.0
PyStemmer==2.0.1
python-dateutil==2.8.2
python-fsutil==0.5.0
python-lsp-jsonrpc==1.0.0
python-lsp-server==1.2.4
python-slugify==5.0.2
pytz==2021.3
PyWebDAV3==0.9.14
PyYAML==5.4.1
pyyaml_env_tag==0.1
pyzmq==22.3.0
qtconsole==5.1.1
QtPy==1.11.2
regex==2021.9.30
requests==2.26.0
requests-oauthlib==1.3.0
rfc3986==1.5.0
rich==10.13.0
rope==0.21.1
rsa==4.7.2
Send2Trash==1.8.0
simplified-scrapy==1.5.164
six==1.16.0
sniffio==1.2.0
snowballstemmer==2.1.0
soupsieve==2.2.1
termcolor==1.1.0
terminado==0.12.1
testpath==0.5.0
text-unidecode==1.3
toml==0.10.2
tornado==6.1
tqdm==4.62.3
traitlets==5.1.0
typing==3.7.4.3
ujson==4.1.0
Unidecode==1.3.2
uritemplate==3.0.1
urllib3==1.26.7
virtualenv==20.8.1
watchdog==2.1.6
wcwidth==0.2.5
webencodings==0.5.1
widgetsnbextension==3.5.1
wrapt==1.12.1
WsgiDAV==3.1.1
xlwt==1.3.0
xmltodict==0.12.0
yapf==0.31.0
zipp==3.6.0