Installation of pip using get-pip.py is breaking. it says
Requirement already up-to-date: pip in /tmp/tmpvF6RoH/pip.zip (10.0.0)
No module named pip.req
while installing a pip module
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from pip.req import parse_requirements
ImportError: No module named pip.req
Solution Idea 1: Install Library pip You need to install it first! Before being able to import the Pandas module, you need to install it using Python's package manager pip . Make sure pip is installed on your machine. This simple command installs pip in your virtual environment on Windows, Linux, and MacOS.
Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process.
Ensure you can run pip from the command line Run python get-pip.py . 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they're not installed already. Be cautious if you're using a Python install that's managed by your operating system or another package manager.
While this error can come due to multiple reasons but in most of the cases you will see this error because of pip package not installed in your System. So to solve this kind of error, you need to simply install pip package from the default Repo.
Installation
For installation using get-pip.py use the --force-reinstall flag:
$ python get-pip.py --force-reinstall
Obviously this is till they fix the problem https://github.com/pypa/pip/issues/5220
Recommended Alternative to pip's internal commands
Avoid putting any dependency links in your requirements.txt
file. Instead use the method mentioned below. You can directly put the dependency links in you setup.py
file. Some famous packages also maintain the requirements inside the setup.py
file in the form of a list and don't have any requirements.txt
file
with open('requirements.txt') as f:
install_requires = f.read().strip().split('\n')
setup(
name='app_name',
.
.
install_requires=install_requires,
dependency_links=[
'https://github.com/frappe/python-pdfkit.git#egg=pdfkit'
],
cmdclass = \
{
'clean': CleanCommand
}
)
Imports from pip (BAD PRACTICE - DO NOT USE as it may break anytime! )
It is highly recommended that you avoid this because, as mentioned in the pip user guide, these methods are not thread safe. Also since they're pip's private methods, they may change it anytime without any prior notice, thereby breaking your package installation!
If you have any imports from pip, such as:
from pip.req import parse_requirements
it'll break. Since these have been now moved to pip._internal as such:
from pip._internal.req import parse_requirements
However effectively you'll have to use something like this for backward compatibility:
try: # for pip >= 10
from pip._internal.req import parse_requirements
except ImportError: # for pip <= 9.0.3
from pip.req import parse_requirements
Important
Now that said it's not a good practice to use the internal pip functions, due to multiple reasons as mentioned here: https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With