I'm encountering an issue while trying to install the dependencies for my Python project using pip install -r requirements.txt
.
The error I'm receiving: It's due to -e . present in requirements.txt
× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [3 lines of output] error in ML_Project setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected package name at the start of dependency specifier -e . ^ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details
and this is what my requirements.txt
looks like:
pandas numpy seaborn -e .
this is my setup.py
:
from setuptools import setup, find_packages from typing import List HYPEN_E_DOT = "-e ." def get_requirements(file_path: str) -> List[str]: ''' This function will return the list of requirements from the requirements.txt file ''' requirements = [] with open(file_path) as file_obj: requirements = file_obj.readlines() requirements = [req.replace("\n", " ") for req in requirements] if HYPEN_E_DOT in requirements: requirements.remove(HYPEN_E_DOT) return requirements setup( name='ML_Project', version='0.0.1', author='author', author_email= '[email protected]', packages=find_packages(), install_requires= get_requirements('requirements.txt') )
I looked the solution online but everywhere it suggests to remove "-e ." I want to keep "-e ." in setup.py.
The error is basically coming because in requirements.txt file you have placed a traling extra space after "-e .". remove that extra space and it will work perfectly.