2015-12-05 180 views
3

我想在Ubuntu服務器上設置一個Python2.7環境。使用requirements.txt我們從pip freeze得到開發系統上,在服務器上運行無法'點安裝-r requirements.txt'

pip install -r requirements.txt 

給出:

Collecting abstract-rendering==0.5.1 (from -r requirements.txt (line 1)) 
    Using cached abstract_rendering-0.5.1.tar.gz 
    Complete output from command python setup.py egg_info: 
    Traceback (most recent call last): 
     File "<string>", line 20, in <module> 
     File "/tmp/pip-build-JhBJBA/abstract-rendering/setup.py", line 6, in <module> 
     from numpy import get_include 
    ImportError: No module named numpy 

    ---------------------------------------- 
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-JhBJBA/abstract-rendering 

所以我用

pip install numpy 

手動安裝numpy,但給人的長錯誤輸出以

結尾
 File "/tmp/pip-build-2uW9Y2/numpy/numpy/distutils/command/build_src.py", line 386, in generate_sources 
     source = func(extension, build_dir) 
     File "numpy/core/setup.py", line 669, in get_mathlib_info 
     raise RuntimeError("Broken toolchain: cannot link a simple C program") 
    RuntimeError: Broken toolchain: cannot link a simple C program 

    ---------------------------------------- 
Command "/usr/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-2uW9Y2/numpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ZQ5XJ7-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-2uW9Y2/numpy 

任何想法如何正確地設置服務器上的Python環境?以下是requirements.txt文件。

abstract-rendering==0.5.1 
alabaster==0.7.6 
anaconda-client==1.1.0 
appnope==0.1.0 
appscript==1.0.1 
argcomplete==1.0.0 
astropy==1.0.5 
Babel==2.1.1 
backports-abc==0.4 
backports.ssl-match-hostname==3.4.0.2 
bcolz==0.12.0 
beautifulsoup4==4.3.2 
binstar==0.11.0 
bitarray==0.8.1 
blaze==0.8.3 
blz==0.6.2 
bokeh==0.10.0 
boto==2.38.0 
boto3==1.2.2 
botocore==1.3.8 
Bottleneck==1.0.0 
bz2file==0.98 
cdecimal==2.3 
certifi==14.5.14 
cffi==1.2.1 
clyent==0.4.0 
colorama==0.3.3 
configobj==5.0.6 
cryptography==1.0.2 
cssselect==0.9.1 
cv2==1.0 
cycler==0.9.0 
Cython==0.23.4 
cytoolz==0.7.4 
datashape==0.4.7 
decorator==4.0.4 
docopt==0.6.2 
docutils==0.12 
enum34==1.0.4 
et-xmlfile==1.0.1 
fastcache==1.0.2 
findspark==0.0.5 
Flask==0.10.1 
funcsigs==0.4 
functools32==3.2.3.post2 
futures==3.0.3 
gdbn==0.1 
gensim==0.12.2 
gevent==1.0.1 
gevent-websocket==0.9.3 
gnumpy==0.2 
greenlet==0.4.9 
grin==1.2.1 
h5py==2.5.0 
httpretty==0.8.6 
idna==2.0 
ipaddress==1.0.14 
ipykernel==4.1.1 
ipython==4.0.0 
ipython-genutils==0.1.0 
ipywidgets==4.1.0 
itsdangerous==0.24 
jdcal==1.0 
jedi==0.9.0 
Jinja2==2.8 
jmespath==0.9.0 
joblib==0.9.2 
jsonschema==2.4.0 
jupyter==1.0.0 
jupyter-client==4.1.1 
jupyter-console==4.0.3 
jupyter-core==4.0.6 
Keras==0.2.0 
Lasagne==0.1 
llvmlite==0.7.0+3.g1ec568f 
lxml==3.4.4 
MarkupSafe==0.23 
matplotlib==1.4.3 
mistune==0.7.1 
mock==1.0.1 
multipledispatch==0.4.8 
nbconvert==4.0.0 
nbformat==4.0.1 
networkx==1.10 
nltk==3.1 
nolearn==0.6a0.dev0 
nose==1.3.7 
notebook==4.0.6 
numba==0.21.0 
numexpr==2.4.4 
numpy==1.10.1 
odo==0.3.4 
openpyxl==2.2.6 
pandas==0.17.0 
path.py==0.0.0 
patsy==0.4.0 
Pattern==2.6 
pbr==1.8.1 
pep8==1.6.2 
pexpect==3.3 
pickleshare==0.5 
Pillow==3.0.0 
ply==3.8 
psutil==3.2.2 
ptyprocess==0.5 
PuLP==1.6.0 
py==1.4.30 
pyasn1==0.1.9 
PyAudio==0.2.7 
pycosat==0.6.1 
pycparser==2.14 
pycrypto==2.6.1 
pycryptodome==3.3.1 
pycurl==7.19.5.1 
pyflakes==1.0.0 
Pygments==2.0.2 
pymongo==3.0.3 
pyOpenSSL==0.15.1 
pyparsing==2.0.3 
pyquery==1.2.9 
pytest==2.8.1 
python-dateutil==2.4.2 
pytz==2015.7 
PyYAML==3.11 
pyzmq==14.7.0 
qtconsole==4.1.0 
redis==2.10.3 
requests==2.8.1 
rope==0.10.3 
runipy==0.1.3 
scikit-image==0.11.3 
scikit-learn==0.16.1 
scipy==0.16.0 
seaborn==0.6.0 
secret==0.5.1 
simplegeneric==0.8.1 
singledispatch==3.4.0.3 
six==1.10.0 
sklearn==0.0 
smart-open==1.3.0 
snowballstemmer==1.2.0 
sockjs-tornado==1.0.1 
Sphinx==1.3.1 
sphinx-rtd-theme==0.1.7 
spyder==2.3.7 
SQLAlchemy==1.0.9 
statsmodels==0.6.1 
sympy==0.7.6.1 
tables==3.2.2 
tabulate==0.7.5 
tensorflow==0.5.0 
terminado==0.5 
Theano==0.7.0 
toolz==0.7.4 
tornado==4.2.1 
traitlets==4.0.0 
trollius==2.0 
ujson==1.33 
unicodecsv==0.14.1 
Werkzeug==0.10.4 
wheel==0.26.0 
xlrd==0.9.4 
XlsxWriter==0.7.7 
xlwings==0.4.1 
xlwt==1.0.0 

回答

5

安裝numpy通常需要一個工作的C編譯器環境。由於這可能是一項乏味的任務,人們喜歡使用(科學)python發行版,如anaconda。至少你需要一個cpmpiler和python頭文件,可能更多。如果您沒有使用python包和C擴展的經驗,請選擇anaconda & co。你會發現許多關於pip和numpy等的答案。

sudo apt-get install build-essential python-dev