我正在尝试使用pypy解释器在虚拟环境中安装我的python包。我在CentOS 7上工作,我做了以下工作:
1)用pypy创建virtualenv:
virtualenv -p /usr/bin/pypy pypy-env
2)使用以下方法激活它:
source pypy-env/bin/activate
3)尝试使用以下方法安装我的包:
pip install .
最后一个命令失败并出现以下错误:
Running setup.py install for matplotlib ... error
Complete output from command /network-raid/opt/python/virtualenvs/pypy-env/bin/pypy -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-iiZlol/matplotlib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-57lig2-record/install-record.txt --single-version-externally-managed --compile --install-headers /network-raid/opt/python/virtualenvs/pypy-env/include/site/python2.7/matplotlib:
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [2.1.0]
python: yes [2.7.10
(bbd45126bc691f669c4ebdfbd74456cd274c6b92, Jun 30
2016, 15:15:02) [PyPy 5.0.1 with GCC 4.8.5 20150623
(Red Hat 4.8.5-4)]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.10.0]
six: yes [using six version 1.11.0]
dateutil: yes [using dateutil version 2.6.1]
backports.functools_lru_cache: yes [using backports.functools_lru_cache]
/network-raid/opt/python/virtualenvs/pypy-env/site-packages/subprocess32.py:472: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
"program uses threads.", RuntimeWarning)
subprocess32: yes [using subprocess32]
pytz: yes [using pytz version 2017.3]
cycler: yes [using cycler version 0.10.0]
tornado: yes [tornado was not found. It is required for the
WebAgg backend. pip/easy_install may attempt to
install it after matplotlib.]
pyparsing: yes [using pyparsing version 2.2.0]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
freetype: yes [version 2.4.11]
png: yes [version 1.5.13]
qhull: yes [pkg-config information for 'libqhull' could not
be found. Using local copy.]
OPTIONAL SUBPACKAGES
sample_data: yes [installing]
toolkits: yes [installing]
tests: no [skipping due to configuration]
toolkits_tests: no [skipping due to configuration]
OPTIONAL BACKEND EXTENSIONS
macosx: no [Mac OS-X only]
qt5agg: no [PySide2 not found; PyQt5 not found]
qt4agg: no [PySide not found; PyQt4 not found]
gtk3agg: no [Requires pygobject to be installed.]
gtk3cairo: no [Requires cairocffi or pycairo to be installed.]
gtkagg: no [Requires pygtk]
tkagg: yes [installing; run-time loading from Python Tcl /
Tk]
wxagg: no [requires wxPython]
gtk: no [Requires pygtk]
agg: yes [installing]
cairo: no [cairocffi or pycairo not found]
windowing: no [Microsoft Windows only]
OPTIONAL LATEX DEPENDENCIES
dvipng: yes [version 1.14]
ghostscript: yes [version 9.07]
latex: yes [version 3.1415926]
pdftops: yes [version 0.26.5]
OPTIONAL PACKAGE DATA
dlls: no [skipping due to configuration]
running install
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-x86_64-2.7/matplotlib/mpl-data
UPDATING build/lib.linux-x86_64-2.7/matplotlib/_version.py
set build/lib.linux-x86_64-2.7/matplotlib/_version.py to '2.1.0'
running build_ext
building 'matplotlib.ft2font' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
cc -O2 -fPIC -Wimplicit -DFREETYPE_BUILD_TYPE=system -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -I/network-raid/opt/python/virtualenvs/pypy-env/include -I/network-raid/opt/python/virtualenvs/pypy-env/include -I/usr/include/freetype2 -I/usr/local/include -I/usr/include -I. -I/network-raid/opt/python/virtualenvs/pypy-env/include -c src/ft2font.cpp -o build/temp.linux-x86_64-2.7/src/ft2font.o
cc1plus: warning: command line option ‘-Wimplicit’ is valid for C/ObjC but not for C++ [enabled by default]
cc -O2 -fPIC -Wimplicit -DFREETYPE_BUILD_TYPE=system -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -I/network-raid/opt/python/virtualenvs/pypy-env/include -I/network-raid/opt/python/virtualenvs/pypy-env/include -I/usr/include/freetype2 -I/usr/local/include -I/usr/include -I. -I/network-raid/opt/python/virtualenvs/pypy-env/include -c src/ft2font_wrapper.cpp -o build/temp.linux-x86_64-2.7/src/ft2font_wrapper.o
cc1plus: warning: command line option ‘-Wimplicit’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /usr/include/numpy/ndarrayobject.h:26:0,
from src/file_compat.h:7,
from src/ft2font_wrapper.cpp:3:
/usr/include/numpy/__multiarray_api.h: In function ‘int _import_array()’:
/usr/include/numpy/__multiarray_api.h:1651:13: error: ‘NPY_CPU_UNKNOWN_ENDIAN’ was not declared in this scope
if (st == NPY_CPU_UNKNOWN_ENDIAN) {
^
/usr/include/numpy/__multiarray_api.h:1662:13: error: ‘NPY_CPU_LITTLE’ was not declared in this scope
if (st != NPY_CPU_LITTLE) {
^
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/network-raid/opt/python/virtualenvs/pypy-env/bin/pypy -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-iiZlol/matplotlib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-57lig2-record/install-record.txt --single-version-externally-managed --compile --install-headers /network-raid/opt/python/virtualenvs/pypy-env/include/site/python2.7/matplotlib" failed with error code 1 in /tmp/pip-build-iiZlol/matplotlib/
我被定位在包含我的包的setup.py的目录中。我的setup.py文件的内容是:
#!/usr/bin/env python
"""
My package setup script.
"""
from setuptools import setup
setup(name='viz_tools',
version='1.0',
setup_requires=[
'numpy'
],
install_requires=[
'docopt',
'matplotlib',
'numpy',
'scipy',
'seaborn',
'sklearn'
],
py_modules=[
'common',
'datamanip',
'drawing'
],
scripts=[
'convert_old_data',
'convert_old_iteration_data_to_json',
'generate_heatmap',
'generate_histograms',
'generate_iteration_json',
'generate_min_max_bar'
])
我设法用python(2.7.10)做到了这一点,但它似乎与pypy无关。命令:
pypy --version
产生以下输出:
Python 2.7.10 (bbd45126bc691f669c4ebdfbd74456cd274c6b92, Jun 30 2016,15:15:02)
[PyPy 5.0.1 with GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]