2012-10-18 164 views
0

我一直在嘗試安裝分發的過去幾天的故障排除,所以我可以開始導入第三方模塊。我還沒有用Python幾年,所以我重新記住了一切相當困難的事情。蟒蛇3.2導入問題

我將錯誤追蹤到給定的目錄,但不知道下一步該怎麼做。

我正在運行一個mac版本10.8.2與在Python中運行的Python 3.2。

下面的代碼:

Traceback (most recent call last): 
    File "/Volumes/James Hard Drive/Python/Python_Lessons/3rd_Party_Stuff/easy_install.py", line 5, in <module> 
    from setuptools.command.easy_install import main 
    File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/__init__.py", line 2, in <module> 
    from setuptools.extension import Extension, Library 
    File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/extension.py", line 5, in <module> 
    from setuptools.dist import _get_unpatched 
    File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/dist.py", line 6, in <module> 
    from setuptools.command.install import install 
    File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/command/__init__.py", line 8, in <module> 
    from setuptools.command import install_scripts 
    File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/command/install_scripts.py", line 3, in <module> 
    from pkg_resources import Distribution, PathMetadata, ensure_directory 
    File "/Volumes/James Hard Drive/Python/Python_Lessons/3rd_Party_Stuff/pkg_resources.py", line 45 
    def _bypass_ensure_directory(name, mode=0777): 
              ^
SyntaxError: invalid token 

回答

3

安裝分發(和PIP,virtualenv中):

#!/bin/bash 
# download latest virtualenv.py 
wget https://raw.github.com/pypa/virtualenv/master/virtualenv.py 

# create a bootstrap virtual environment in ./venv directory 
python3 virtualenv.py venv 

要激活的virtualenv:

$ . ./venv/bin/activate 

現在你可以使用pipeasy_install安裝其他軟件包,或者使用virtualenv-3.x創建新virtualenvs 。

如果您使用許多virtualenvs(不同的項目,不同的python版本);您可以使用pip installvirtualenvwrapper來輕鬆管理它們,例如,workon/mkvirtualenv/rmvirtualenv命令。

+0

快速和容易拉! – user1754959

+0

* wget = curl (15char) – user1754959

+0

@ user1754959:您可能的意思是'curl -O' – jfs

2

的問題是,Python 3中不同的方式解釋八進制數比Python 2.x版本在2.x中,你可以在0前加一個數字來表示它是八進制的。在Python 3中,您以0o爲前綴,因此您的編號需要爲0o777

def _bypass_ensure_directory(name, mode=0o777): 

有關更多詳細信息,請參見http://docs.python.org/release/3.0.1/whatsnew/3.0.html#integers

+1

謝謝...幫我看看它是從錯誤的文件 – user1754959