问题描述
我在过去几天一直在尝试安装分发版本,因此我可以开始导入第三方模块。我没有使用python几年,所以我重新记住了一切相当困难的东西。
I've been troubleshooting for the past few days trying to install distribute so I can start importing 3rd party modules. I haven't used python for a couple years so I'm re-remembering everything which has been pretty difficult.
我将错误跟踪到了给定的目录,但不知道下一步该怎么做。
I followed the errors to the directories given but don't know what to do next.
我'运行mac版本10.8.2,在Eclipse中运行python 3.2。
I'm running a mac version 10.8.2 with python 3.2 running in Eclipse.
这里是代码:
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
推荐答案
安装distribute(和pip,virtualenv):
To install distribute (and 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:
To activate virtualenv:
$ . ./venv/bin/activate
现在你可以使用 pip
, easy_install
安装其他软件包或使用 virtualenv-3.x
创建新的virtualenvs。
Now you could use pip
, easy_install
to install other packages or use virtualenv-3.x
to create new virtualenvs.
如果你使用很多virtualenvs(不同的项目,不同的python版本);你可以 pip install
来管理它们很容易,例如 workon / mkvirtualenv / rmvirtualenv
命令。
If you use many virtualenvs (different projects, different python versions); you could pip install
virtualenvwrapper to manage them easily e.g., workon/mkvirtualenv/rmvirtualenv
commands.
这篇关于python 3.2导入问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!