我有关于Pythonpath的问题。
当我打印sys.path的内容时,系统版本出现在Macports版本之前。如何更改路径,使macports版本永久出现在系统版本之前,我不想在每个程序的开头反转路径。如果您有兴趣,这就是整条路径:
['', '/Library/Python/2.7/site-packages/pyglet-1.1.4-py2.7.egg', '/Library/Python/2.7/site-packages/greenlet-0.3.1-py2.7-macosx-10.7-intel.egg', '/Library/Python/2.7/site-packages/cocos2d-0.4.0-py2.7.egg', '/Library/Python/2.7/site-packages/simplejson-2.1.6-py2.7-macosx-10.7-intel.egg', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyObjC', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info', '/Library/Python/2.7/site-packages']
答案 0 :(得分:0)
这样做:sys.path.append(“这里的新路径”)