2012-01-03 10 views
22

के साथ निर्भरता के रूप में numpy को स्थापित करना यह this एक का अनुवर्ती प्रश्न हो सकता है।setuptools

मैं अपने पैकेज को स्थापित करने के लिए setuptools का उपयोग कर रहा हूं। एक निर्भरता के रूप में मैंने numpy सूचीबद्ध किया है। मैं Python2.7 उपयोग कर रहा हूँ और जब मैं इस setup.py फ़ाइल के साथ

python setup.py install 

कार्य करें:

from setuptools import setup 

setup(name = "test_pack", install_requires = ["numpy"]) 

मैं इस त्रुटि संदेश के साथ अंत:

ImportError: No module named numpy.distutils 

मैं क्या करने की जरूरत है numpy को निर्भरता के रूप में शामिल करने के लिए और इसे python-dev स्थापित किए बिना इंस्टॉल करें?


python setup.py install की पूरी उत्पादन: numpy के लिए

running install 
running bdist_egg 
running egg_info 
writing requirements to test_pack.egg-info/requires.txt 
writing test_pack.egg-info/PKG-INFO 
writing top-level names to test_pack.egg-info/top_level.txt 
writing dependency_links to test_pack.egg-info/dependency_links.txt 
reading manifest file 'test_pack.egg-info/SOURCES.txt' 
writing manifest file 'test_pack.egg-info/SOURCES.txt' 
installing library code to build/bdist.linux-x86_64/egg 
running install_lib 
creating build/bdist.linux-x86_64/egg 
creating build/bdist.linux-x86_64/egg/test_pack 
copying build/lib/test_pack/__init__.py -> build/bdist.linux-x86_64/egg/test_pack 
copying build/lib/test_pack/mod.py -> build/bdist.linux-x86_64/egg/test_pack 
byte-compiling build/bdist.linux-x86_64/egg/test_pack/__init__.py to __init__.pyc 
byte-compiling build/bdist.linux-x86_64/egg/test_pack/mod.py to mod.pyc 
creating build/bdist.linux-x86_64/egg/EGG-INFO 
copying test_pack.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO 
copying test_pack.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO 
copying test_pack.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO 
copying test_pack.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO 
copying test_pack.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO 
creating 'dist/test_pack-0.0.0-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it 
removing 'build/bdist.linux-x86_64/egg' (and everything under it) 
Processing test_pack-0.0.0-py2.7.egg 
Copying test_pack-0.0.0-py2.7.egg to /home/woltan/local/lib/python2.7/site-packages 
Adding test-pack 0.0.0 to easy-install.pth file 

Installed /home/woltan/local/lib/python2.7/site-packages/test_pack-0.0.0-py2.7.egg 
Processing dependencies for test-pack==0.0.0 
Searching for numpy 
Reading http://pypi.python.org/simple/numpy/ 
Reading http://numpy.scipy.org 
Reading http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103 
Reading http://numeric.scipy.org 
Best match: numpy 1.6.1 
Downloading http://pypi.python.org/packages/source/n/numpy/numpy-1.6.1.zip#md5=462c22b8eb221c78ddd51de98fbb5979 
Processing numpy-1.6.1.zip 
Running numpy-1.6.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-AoFmdV/numpy-1.6.1/egg-dist-tmp-JH1j2R 
non-existing path in 'numpy/distutils': 'site.cfg' 
Could not locate executable g77 
Found executable /opt/solstudio12.2/bin/f77 
gnu: no Fortran 90 compiler found 
gnu: no Fortran 90 compiler found 
Found executable /opt/intel/Compiler/11.1/073/bin/intel64/ifort 
Could not locate executable lf95 
Could not locate executable pgf90 
Could not locate executable pgf77 
Found executable /opt/solstudio12.2/bin/f90 
Found executable /opt/solstudio12.2/bin/f95 
Could not locate executable fort 
_configtest.c:1: warning: conflicting types for built-in function ‘exp’ 
_configtest.o: In function `main': 
/tmp/easy_install-AoFmdV/numpy-1.6.1/_configtest.c:6: undefined reference to `exp' 
collect2: ld returned 1 exit status 
_configtest.c:1: warning: conflicting types for built-in function ‘exp’ 
_configtest.c:1:20: error: Python.h: No such file or directory 
_configtest.o: In function `main': 
/tmp/easy_install-AoFmdV/numpy-1.6.1/_configtest.c:6: undefined reference to `exp' 
collect2: ld returned 1 exit status 
_configtest.c:1:20: error: Python.h: No such file or directory 

उत्तर

3

जब तक आप एक द्विआधारी वितरण के लिए उपयोग किया (/ बनाया पूर्व संकलित), तुम अजगर यह के रूप में उपलब्ध हेडर के लिए होगा उन्हें numpy बनाने की जरूरत है। यही कारण है कि अधिकांश पैकेज प्रबंधक इन पैकेजों के पूर्व-संकलित संस्करणों के साथ आते हैं। उदाहरण के लिए आप apt-get install python-numpy कर सकते हैं, जो आपके वर्चुअलएन्व में लिंक करें, और जब आप install_requires=['numpy'] के साथ अपना प्रोग्राम इंस्टॉल करने का प्रयास करते हैं तो इसे देखना चाहिए कि यह पहले से इंस्टॉल है।

+1

की तरह कुछ वहाँ एक रास्ता 'numpy' यह स्थापित करने से पहले निर्माण करने के लिए' setuptools' बताने के लिए नहीं है? अपने स्वयं के कार्यों पर 'numpy' को बिल्ड और इंस्टॉल करना ... – Woltan

+0

मुझे खेद है कि मैं इसका पालन नहीं करता हूं। आपके चिपकाए आउटपुट से ** ** ** numpy बनाने का प्रयास कर रहा है। –

+0

ठीक है, लेकिन मैं इसे 'numpy' डाउनलोड करने और इंस्टॉल करने में सक्षम हूं (' setuptools' के साथ नहीं)। केवल अगर मैं इसे 'setuptools' के साथ बनाने और स्थापित करने का प्रयास करता हूं तो यह टूट जाता है। – Woltan

2

numpy स्थापित करने के लिए setuptools पैकेज डाउनलोड करेगा और इसे स्रोत से संकलित करेगा। हालांकि, numpy संकलित करने के लिए कुछ और आवश्यकताएं हैं, आप इसे here देख सकते हैं।

_configtest.c:1:20: error: Python.h: No such file or directory 

इस त्रुटि इंगित करता है कि कम से कम आप अजगर-देव पैकेज स्थापित नहीं है (यदि आप ubuntu उपयोग कर रहे हैं/डेबियन)।

5

यह ज्ञात मुद्दा है, numpy/numpy #2434 पर ट्रैक किया गया।

मुझे इसके लिए एक समाधान मिला: numpysetup_requires जोड़ें। setup_requires और install_requires दोनों में यह setuptools के नवीनतम संस्करण के साथ ठीक काम करता प्रतीत होता है।

तो, अपने setup.py दिखना चाहिए

setup(
    # Your setup specific stuff here 
    setup_requires=["numpy"], # Just numpy here 
    install_requires=["numpy"], # Add any of your other dependencies here 
) 
+0

'setup_requires' में numpy जोड़ना पर्याप्त नहीं था। मुझे सफलतापूर्वक numpy इंस्टॉल करने के लिए 'python setup.py unstall' को दो बार चलाने के लिए भी था, http://stackoverflow.com/questions/21605927/why-doesnt-setup-requires-work-properly-for-numpy – asmaier

संबंधित मुद्दे