As a well-supported language with countless contributors and user-contributed modules, Python is currently as versatile as it can.
Python can be used to power endless projects, from a government-scale data processing project to small tweaks for smartphones running abandonware operating systems.
User-contributed modules are the beauty of Python – those modules extend Python’s usability and flexibility, and some modules even became so widely used that it was introduced as standard module.
Finding modules for Python is also easy, thanks to the pip repository. Gone are the days when you need to hunt down every .py
file in existence – now, if you need a module or function, you can just invoke pip to download and install modules from its repository and start using it in your program.
The curated nature of pip also increases the security of your code. When using modules from pip, you can auto-update them as soon as an update is released. This centralized approach and tight-knit community also become a reason why people are so invested in Python.
However, just like any software in this world, nothing is bug-free. Sometimes bugs and errors come at random, leaving users clueless, and pip is no exception to this rule.
What Caused the Error
Under certain conditions, Python can fail to import some modules, and one of the most common modules to fail is “typing”. This useful module is used by developers as type checkers, which is needed as Python needs to determine object types at runtime.
With type hinting made possible by typing module, Python codes can be much more readable to developers and reliable when it is run.
In this article, we will talk about ways to fix the dreaded “Pip “ImportError: No Module Named Typing” error”. Some terminal knowledge and internet connection are needed.
How to Fix the Error
The first step to fix this problem is by reinstalling the typing module through pip repository. You can do so by issuing the following command:
pip install typing
Pip will try to reinstall the module and after it finished running, you can try using typing again.
However, sometimes pip can also fail, and when it happens, we need to upgrade our pip install. Begin with the following command:
pip install --upgrade pip
Pip will be reinstalled and upgraded afterward. However, if for any reason pip was still unable to import typing, you can try reinstalling pip the old way by using.py
script.
Issue this command to download get-pip.py
script from the official server:
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
After the get-pip.py
script is downloaded, launch it through the command:
python get-pip.py
In most cases, reinstalling typing module after reinstalling pip will fix your issues. If pip still fails to import typing module, some more updates on the operating system level.
Assuming you are using a Debian Linux-baed distribution (such as Ubuntu, Mint, and countless other distributions), you can issue this simple command to update the repository list on your computer:
sudo apt-get update
And afterward, use this command to update all packages installed on your system:
sudo apt-get upgrade
Wait until all your packages are upgraded. You might need to reboot the computer after apt-get upgrade.
Try importing typing again to see what happens. If it still won’t import, you can try this last resort method. First, issue a command to fix broken installs on your system:
sudo apt --fix-broken-install
Your distribution package manager will try to resolve dependency issues or any conflicts that prevent Python from working properly.
Afterward, use the upgrade command mentioned earlier to get and automatically install all updated packages for your system. Then, following a reboot, try re-importing the module typing, pip should be able to detect it now.
We are a bunch of people who are still continue to learn Linux servers. Only high passion keeps pushing us to learn everything.