小编典典

python 3.2导入问题

python

过去几天,我一直在进行故障排除,以尝试安装分发服务器,以便可以开始导入第三方模块。我已经有两年没有使用python了,所以我想起了所有很难的东西。

我将错误跟踪到给定的目录,但不知道下一步该怎么做。

我正在运行带有Eclipse 3.2的python 3.2的mac版本10.8.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

阅读 322

收藏
2021-01-20

共1个答案

小编典典

要安装分发(和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命令。

2021-01-20