python pycparser setup error

2019-03-27 14:27发布

I am seeing the following error while setting up pyparser on CentOS 7 via pip


/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-PMzCYU/pycparser/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-0bpBrX-record/install-record.txt --single-version-externally-managed --compile
Traceback (most recent call last):

File "", line 1, in init.py", line 12, in import setuptools.version File "/usr/lib/python2.7/site-packages/setuptools/version.py", line 1, in import pkg_resources File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 72, in import packaging.requirements File "/usr/lib/python2.7/site-packages/packaging/requirements.py", line 59, in MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker") TypeError: call() takes exactly 2 arguments (1 given)

3条回答
何必那么认真
2楼-- · 2019-03-27 15:05

Note: Running Python 2.7.10 on Macbook Yosmite, attempting install of TensorFlow, using pip. Any attempt to install or upgrade "numpy", in order to resolve Tensorflow dependency issue on 'numpy' version, generates error as follows:

TypeError: __call__() takes exactly 2 arguments (1 given)

I had installed, via pip, latest Tensorflow, which loaded many packages. This broke pip. All attempts to run pip generated same errors as post above, with final line being:

TypeError: __call__() takes exactly 2 arguments (1 given)

including the pip install setuptools==33.1.1 suggestion provided above. The TensorFlow install pooched my pip version, bad pyparser code, looks like. Remember, I'm running Python 2.7.x..

The resolution suggested to pip install setuptool==33.1.1 generates same error sequence, since the Python 2.7 parser was broken. pip and also easy_install were broken. I could not even update pip using get-pip.py. Running python get-pip.py generates essentially the same error sequence shown above. Really maximal NFG.

[So, the solution...] Found the solution piecing together from other posts: The "requirements.py" (a pyparser prgm?) has an error in it, which can be fixed by finding the code and editing the file. On my Macbook, the file is in: /Library/Python/2.7/site-packages/packaging

Find the python prgm called: requirements.py Change line 59:

MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")

To:

MARKER_EXPR = originalTextFor(MARKER_EXPR(""))("marker")

I've confirmed that this change lets pip and easy_install run again. Also, on Linux, one could also provoke the error by just running, in Python:

    from pkg_resources import load_entry_point 

Confirmed that this now works in Python 2.7.10 on Mac OS 10.10.5, after the fix to requirements.py.

查看更多
劳资没心,怎么记你
3楼-- · 2019-03-27 15:12

same solution worked for me

pip install setuptools==33.1.1 and then sudo pip install -r requirements.txt

查看更多
迷人小祖宗
4楼-- · 2019-03-27 15:18

This appears to be caused by https://github.com/pypa/setuptools/commit/ff371f18f0076bc63da05334f7e551c1cc29e10d which was released in v34.0.0 of setuptools. This commit removed the vendoring of several packages. Also looks like this only affects new setuptools installs. Existing ones are fine on 34.0.2

Work around via hard coding the version:

pip install setuptools==33.1.1

Still working out how to fix pip usage once >= 34.0.0 is installed,

EDIT: this is by design "Setuptools no longer supports self upgrade or installation in the general case." http://setuptools.readthedocs.io/en/latest/history.html#v34-0-0

查看更多
登录 后发表回答