2014-01-24 30 views
-1

我真的需要我的Mac上pycurl。安裝Xcode修復了大部分python缺失的庫問題?

我在我的Mac上運行python代碼時遇到了很多麻煩,主要是因爲我幾乎沒有任何庫可以使用。例如,如果我輸入

import pycurl 

給我的錯誤:

ImportError: No module named pycurl

好涼,所以讓我們再安裝pycurl用pycurl-7.19.3:

Matts-MacBook-Pro:pycurl-7.19.3 CiniCraft$ python setup.py install 
Using curl-config (libcurl 7.21.4) 
running install 
running build 
running build_py 
running build_ext 
Traceback (most recent call last): 
    File "setup.py", line 487, in <module> 
    setup(**setup_args) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup 
    dist.run_commands() 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands 
    self.run_command(cmd) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command 
    cmd_obj.run() 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 563, in run 
    self.run_command('build') 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command 
    self.distribution.run_command(command) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command 
    cmd_obj.run() 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run 
    self.run_command(cmd_name) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command 
    self.distribution.run_command(command) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command 
    cmd_obj.run() 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 307, in run 
    customize_compiler(self.compiler) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/sysconfig.py", line 170, in customize_compiler 
    _osx_support.customize_compiler(_config_vars) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_osx_support.py", line 418, in customize_compiler 
    _find_appropriate_compiler(_config_vars) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_osx_support.py", line 191, in _find_appropriate_compiler 
    "Cannot locate working compiler") 
SystemError: Cannot locate working compiler 

當然,那也不行,所以讓easy_install吧:

sudo easy_install pycurl 


Searching for pycurl 
Reading http://pypi.python.org/simple/pycurl/ 
Best match: pycurl 7.19.3 
Downloading https://pypi.python.org/packages/source/p/pycurl/pycurl-7.19.3.tar.gz#md5=b9091b7438d3de1552e28862d2971cd1 
Processing pycurl-7.19.3.tar.gz 
Running pycurl-7.19.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-d16j45/pycurl-7.19.3/egg-dist-tmp-6PRcV6 
Using curl-config (libcurl 7.21.4) 
unable to execute llvm-gcc-4.2: No such file or directory 
error: Setup script exited with error: command 'llvm-gcc-4.2' failed with exit status 1 

我認爲在這一點上,我已經嘗試了一切...我正在下載Xcode 4.2.1舊版本的OS X 10.7.3

Xcode是否應該添加我需要的所有python庫並希望解決我的大部分問題?

+0

我們應該如何知道你需要哪些庫以及你的問題是什麼? – 2014-01-24 05:30:56

+0

啊對不起,現在我真的需要pycurl – user1504605

回答

0
  1. 從App Store
  2. 在Xcode安裝最新版本的Xcode,去首選項 - >下載 - >組件
  3. 下載一個命令行工具

,然後繼續前進,安裝pycurl