python - 在 Python 3.3 venv (OS X/Homebrew) 中安装 distribute

标签 python macos homebrew python-3.3

我一直在尝试在我的 OS X 机器上启动并运行 Python 3.3 的内置“venv”模块。我已经使用 Homebrew 安装了 Python 3.3。

根据文档,创建和切换虚拟环境的工作方式与您预期的一样:

$ python3 -m venv myvenv
$ source myvenv/bin/activate

我测试过这样的东西:

$ echo "YEAH = 'YEAH!'" > myvenv/lib/python3.3/site-packages/thingy.py
$ python
>>> import thingy
>>> print(thingy.YEAH)
'YEAH!'

但是当我尝试安装 distribute 时,它​​根本不会安装在正确的位置。出于某种原因,它坚持尝试安装到 /usr/local/lib/python3.3/site-packages/,但失败并显示以下消息:

No setuptools distribution found
running install
Checking .pth file support in /usr/local/lib/python3.3/site-packages/
/Users/victor/myvenv/bin/python -E -c pass
TEST FAILED: /usr/local/lib/python3.3/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python3.3/site-packages/

and your PYTHONPATH environment variable currently contains:

    ''

无论我尝试使用 distribute_setup.py 还是直接使用源代码分发,都会发生这种情况。我什至尝试过使用 --prefix=/Users/victor/myenv 但它仍然试图将所有内容放入我的“全局”站点包中。

我不明白为什么会这样,但它在我的两台机器上是一致的。请注意,sys.prefix 报告了正确的路径(虚拟环境)。

这是 Homebrew 的问题吗?操作系统? python 3.3?静脉?我?

最佳答案

这一直是 Homebrew 的问题,是的,但自 https://github.com/mxcl/homebrew/commit/0b50110107ea2998e65011ec31ce45931b446dab 以来它现在正在工作。 .

$ brew update
$ brew rm python3  #if you have installed it before
$ brew install python3
$ cd /tmp
$ which python3
  /usr/local/bin/python3
$ python3 -m venv myvenv 
$ source myvenv/bin/activate
$ wget http://python-distribute.org/distribute_setup.py  # may need brew install wget
$ python3 distribute_setup.py  
  ...
  Finished processing dependencies for distribute==0.6.45
  After install bootstrap.
  Creating /private/tmp/myvenv/lib/python3.3/site-packages/setuptools-0.6c11-py3.3.egg-info
  Creating /private/tmp/myvenv/lib/python3.3/site-packages/setuptools.pth

您会看到分发安装已成功进入/tmp 目录。

关于python - 在 Python 3.3 venv (OS X/Homebrew) 中安装 distribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14097423/

相关文章:

objective-c - 为什么无法从 Objective-C 目标文件中隐藏符号?

mysql - OSX 10.9.5 brew 安装 mysql - "The post-install step did not complete successfully"

xcode - 为什么 Homebrew 报告 "couldn' t 理解 kern.osversion `14.0.0'”?

Mac OS X 10.8.5 上的 MySQL 连接错误

python - 似乎无法在原始 Python 中编写两个 channel Wave 文件(无 Wave 模块)

python - 在没有管理员权限的情况下安装 Python/Matlab 库?

python - 为什么这行代码会产生 TypeError : 'tuple' object cannot be interpreted as an integer

swift - 在没有 nib 的情况下使用 NSTableView 创建 NSScrollView——缺少对 TableView 的约束

javascript - 将坐标值转换为fixed64 protobuf对象

swift - 加载时从 WebView 获取 URL。 swift