[Solved]Command "python setup.py egg_info" failed with error code 1

You have custom app and on bench update fails with below error

Command “python setup.py egg_info” failed with error code 1

File “/home/ashish/bench-repo/bench/utils.py”, line 159, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: ./env/bin/pip install -q -e ./apps/your_app_name

Solution

Locate setup.py of your app i.e. frappe-bench/apps/your_app_name/setup.py
and correct it i.e. remove
from pip.req import parse_requirements
and instead add the latest code

with open(‘requirements.txt’) as f:
install_requires = f.read().strip().split(‘\n’)

before changes to setup.py it would look like following.

-- coding: utf-8 --

from setuptools import setup, find_packages
from pip.req import parse_requirements
import re, ast

#get version from version variable in plaid_integration/init.py
_version_re = re.compile(r’version\s+=\s+(.*)')

with open(‘plaid_integration/init.py’, ‘rb’) as f:
version = str(ast.literal_eval(_version_re.search(
f.read().decode(‘utf-8’)).group(1)))

requirements = parse_requirements(“requirements.txt”, session=“”)

setup(
name=‘plaid_integration’,
version=version,
description=‘Plaid Integration’,
author=‘ashish-greycube’,
author_email=‘admin@greycube.in’,
packages=find_packages(),
zip_safe=False,
include_package_data=True,
install_requires=[str(ir.req) for ir in requirements],
dependency_links=[str(ir._link) for ir in requirements if ir._link]
)

After correction, it should look like below

-- coding: utf-8 --

from setuptools import setup, find_packages
#from pip.req import parse_requirements
import re, ast

#get version from version variable in plaid_integration/init.py
_version_re = re.compile(r’version\s+=\s+(.*)')

with open(‘requirements.txt’) as f:
install_requires = f.read().strip().split(‘\n’)

with open(‘plaid_integration/init.py’, ‘rb’) as f:
version = str(ast.literal_eval(_version_re.search(
f.read().decode(‘utf-8’)).group(1)))

#requirements = parse_requirements(“requirements.txt”, session=“”)

setup(
name=‘plaid_integration’,
version=version,
description=‘Plaid Integration’,
author=‘ashish-greycube’,
author_email=‘admin@greycube.in’,
packages=find_packages(),
zip_safe=False,
include_package_data=True,
install_requires=install_requires
#dependency_links=[str(ir._link) for ir in requirements if ir._link]
)

2 Likes

@codingCoffee, Ameya I am curious , can you please explain why the above solution works? Thanks!

If I recollect corectly, pip from v10 onwards deprecated pip.req.parse_requirements, hence we had to write a custom function (parse_requirements) to achieve the same functionality.

1 Like

Thanks, that very much explains it

You can know the pip version of bench virtual env using below command
Go to bench

$source ./env/bin/activate
$ pip --version

pip 18.1 from /home/ashish/frappe-bench-master/env/local/lib/python2.7/site-packages/pip (python 2.7)

@jparikh, Thanks! for pointing this

1 Like