所以我第一次使用Python并且遇到了一个错误,谷歌在帮助我弄清楚方面做得不好。
运行OSX Lion 10.7.4,Python 2.7.3,并安装了xCode命令行工具。
我似乎无法安装任何软件包。并继续收到以下错误:
distribute-0.6.26 user$ python setup.py install --prefix=~/.local
Before install bootstrap.
Scanning installed packages
No setuptools distribution found
running install
Traceback (most recent call last):
File "setup.py", line 214, in <module>
scripts = scripts,
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 "/Users/user/distribute-0.6.26/setuptools/command/install.py", line 73, in run
self.do_egg_install()
File "/Users/user/distribute-0.6.26/setuptools/command/install.py", line 82, in do_egg_install
easy_install = self.distribution.get_command_class('easy_install')
File "/Users/user/distribute-0.6.26/setuptools/dist.py", line 362, in get_command_class
self.cmdclass[command] = cmdclass = ep.load()
File "/Users/user/distribute-0.6.26/pkg_resources.py", line 1993, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Users/user/distribute-0.6.26/setuptools/command/easy_install.py", line 26, in <module>
from setuptools.package_index import PackageIndex
File "/Users/user/distribute-0.6.26/setuptools/package_index.py", line 2, in <module>
import sys, os.path, re, urlparse, urllib, urllib2, shutil, random, socket, cStringIO
File "build/bdist.macosx-10.7-intel/egg/urllib2.py", line 110, in <module>
ImportError: cannot import name splitgophertype
我不介意重新安装Python,但我不知道在OSX上实现这一目标的最佳方法。我已经尝试安装pip,以便我可以卸载urllib2,但我无法安装它。
有没有人有任何想法?
由于 -J
添加了dir(urllib)的结果
['ContentTooShortError', 'FancyURLopener', 'MAXFTPCACHE', 'URLopener', '__all__',
'__builtins__', '__doc__', '__file__', '__name__', '__package__', '__version__',
'_ftperrors', '_get_proxies', '_get_proxy_settings', '_have_ssl', '_hexdig', '_hextochr',
'_hostprog', '_is_unicode', '_localhost', '_noheaders', '_nportprog', '_passwdprog',
'_portprog', '_queryprog', '_safe_map', '_safe_quoters', '_tagprog', '_thishost',
'_typeprog', '_urlopener', '_userprog', '_valueprog', 'addbase', 'addclosehook',
'addinfo', 'addinfourl', 'always_safe', 'base64', 'basejoin', 'c', 'ftpcache',
'ftperrors', 'ftpwrapper', 'getproxies', 'getproxies_environment',
'getproxies_macosx_sysconf', 'i', 'localhost', 'noheaders', 'os', 'pathname2url',
'proxy_bypass', 'proxy_bypass_environment', 'proxy_bypass_macosx_sysconf', 'quote',
'quote_plus', 'reporthook', 'socket', 'splitattr', 'splithost', 'splitnport',
'splitpasswd', 'splitport', 'splitquery', 'splittag', 'splittype', 'splituser',
'splitvalue', 'ssl', 'string', 'sys', 'test1', 'thishost', 'time', 'toBytes', 'unquote',
'unquote_plus', 'unwrap', 'url2pathname', 'urlcleanup', 'urlencode', 'urlopen', 'urlretrieve']