2012-12-31 14 views
5

私は、OS XマシンにPython 3.3のビルトイン "venv"モジュールをインストールして起動しようとしていました。私はHomebrewを使ってPython 3.3をインストールしました。ドキュメントを1としてPython 3.3でのディストリビューションのインストールvenv(OS X/Homebrew)

、仮想環境を作成し、スイッチングあなたが期待通りに動作します

$ 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!' 

をしかし、私はインストールしようとすると、配布すると、それは単に適切な場所に行かない。何らかの理由で、それは次のメッセージで失敗した、/usr/local/lib/python3.3/site-packages/にインストールしようとする上で主張:私はdistribute_setup.pyを使用して、または直接ソース配布を使用してインストールしようとした場合

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: 

    '' 

これは関係なく、発生します。私も--prefix=/Users/victor/myenvを使ってみましたが、それでも私の "グローバルな"サイトパッケージにすべてを入れようとしています。

これはなぜ発生するのかわかりませんが、2台のマシンで一貫性があります。 sys.prefixが正しいパス(仮想環境)を報告していることに注意してください。

Homebrewには問題がありますか? OS X? Python 3.3? venv?私?

+2

distribute 0.6.33をvenvにインストールすると、10.8のpython.orgの64ビット/ 32ビットインストーラからpython.org 3.3.0をインストールしても問題ありません。 –

+1

私は、Homebrewの便宜のためにpython.orgの使用を完全に止めました。しかし、彼らのインストーラも私のために働く。だから、HomebrewがPythonをインストールする方法の問題かもしれません。 – vicvicvic

+1

FWIW、MacPortsのpython33ポートでもうまく動作します。だから、自家製のレシピでの欠陥の可能性が最も高い。 –

答えて

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 

distribute installが/ tmpディレクトリに正常にインストールされていることがわかります。

1

homebrewはdistutilsの設定ファイルをインストールするためです:bugs.python.orgで "distutils.cfg Can Break venv" の問題を参照してください

$ brew cat python3 | grep "Tell distutils" -A5 
    # Tell distutils-based installers where to put scripts 
    (prefix/"Frameworks/Python.framework/Versions/#{VER}/lib/python#{VER}/distutils/distutils.cfg").write <<-EOF.undent 
     [install] 
     install-scripts=#{scripts_folder} 
     install-lib=#{site_packages} 
    EOF 

$ mv ~/.local/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/distutils.cfg ~/tmp/ 
$ cat ~/tmp/distutils.cfg 
[install] 
install-scripts=/Users/gatto/.local/share/python3 
install-lib=/Users/gatto/.local/lib/python3.3/site-packages 
$ . venv/bin/activate 
(venv) $ python distribute-0.6.36/distribute_setup.py 
(venv) $ ls venv/lib/python3.3/site-packages/ 
distribute-0.6.36-py3.3.egg easy-install.pth setuptools-0.6c11-py3.3.egg-info setuptools.pth 

を。

+1

Homebrewはこのdistutils.cfgをより標準に準拠した方法に変更しました。 https://github.com/mxcl/homebrew/commit/0b50110107ea2998e65011ec31ce45931b446dab –

関連する問題