2

pyenv仮想環境の設定に, virtualenv, 'autoev` を使用しています。

をインストールPython3.5.1し、Python2.7.9いくつかのプロジェクト仮想環境を作成します。

しかし、各環境をアクティブにしてPythonのバージョンを確認すると、which python同じpython実行ファイルを指します:

  1. Python 3.5.1 env

(chacha_dabang) Chois@Chois-MacPro $ which python
/Users/Chois/.pyenv/shims/python


(chacha_dabang) Chois@Chois-MacPro $ which pip
/Users/Chois/.pyenv/shims/pip


  1. Python 2.7.9 環境

    (pycon2016) Chois@Chois-MacPro $ (マスター) which python
    /Users/Chois/.pyenv/shims/python
    (pycon2016) Chois@Chois-MacPro $ (master) which pip
    /Users/Chois/.pyenv/shims/pip

そして、ディレクトリを次のように変更します: /Users/Chois/.pyenv/shims

Chois@Chois-MacPro pyconapac-2016 $ (master)cd ~/.pyenv/shims/
Chois@Chois-MacPro shims $ls
2to3                    easy_install-2.7        iptest3                 nosetests-3.4           pip2.7                  python3                 rst2xml.py
2to3-3.5                easy_install-3.5        ipython                 painter.py              pip3                    python3-config          rstpep2html.py
__pycache__             enhancer.py             ipython3                painter.pyc             pip3.5                  python3.5               smtpd.py
activate                enhancer.pyc            jsonschema              pep8                    player.py               python3.5-config        sphinx-apidoc
activate.csh            explode.py              jupyter                 pilconvert.py           player.pyc              python3.5m              sphinx-autogen
activate.fish           explode.pyc             jupyter-kernelspec      pilconvert.pyc          pybabel                 python3.5m-config       sphinx-build
activate_this.py        f2py3.5                 jupyter-migrate         pildriver.py            pydoc                   pyvenv                  sphinx-quickstart
coverage                gifmaker.py             jupyter-nbconvert       pildriver.pyc           pydoc3                  pyvenv-3.5              sqlformat
coverage-3.5            gifmaker.pyc            jupyter-nbextension     pilfile.py              pydoc3.5                rst2html.py             thresholder.py
coverage3               idle                    jupyter-notebook        pilfile.pyc             pygmentize              rst2latex.py            thresholder.pyc
createfontdatachunk.py  idle3                   jupyter-qtconsole       pilfont.py              python                  rst2man.py              viewer.py
createfontdatachunk.pyc idle3.5                 jupyter-serverextension pilfont.pyc             python-config           rst2odt.py              viewer.pyc
django-admin            ipcluster               jupyter-troubleshoot    pilprint.py             python2                 rst2odt_prepstyles.py   virtualenv
django-admin.py         ipcontroller            jupyter-trust           pilprint.pyc            python2-config          rst2pseudoxml.py        waitress-serve
django-admin.pyc        ipengine                jwt                     pip                     python2.7               rst2s5.py               wheel
easy_install            iptest                  nosetests               pip2                    python2.7-config        rst2xetex.py

彼らはpython2とpython3の両方を持っています...

特定のプロジェクトを設定すると、次のようなvirtualenv独自の virtualenv になるはずだと思います。python

Chois@Chois-MacPro bin $pwd
/Users/Chois/.pyenv/versions/chacha_dabang/bin
Chois@Chois-MacPro bin $ls
__pycache__             easy_install            iptest3                 jupyter-qtconsole       pildriver.py            python                  rst2xml.py
activate                easy_install-3.5        ipython                 jupyter-serverextension pilfile.py              python3                 rstpep2html.py
activate.csh            enhancer.py             ipython3                jupyter-troubleshoot    pilfont.py              rst2html.py             sphinx-apidoc
activate.fish           explode.py              jsonschema              jupyter-trust           pilprint.py             rst2latex.py            sphinx-autogen
coverage                f2py3.5                 jupyter                 jwt                     pip                     rst2man.py              sphinx-build
coverage-3.5            gifmaker.py             jupyter-kernelspec      nosetests               pip3                    rst2odt.py              sphinx-quickstart
coverage3               ipcluster               jupyter-migrate         nosetests-3.4           pip3.5                  rst2odt_prepstyles.py   sqlformat
createfontdatachunk.py  ipcontroller            jupyter-nbconvert       painter.py              player.py               rst2pseudoxml.py        thresholder.py
django-admin            ipengine                jupyter-nbextension     pep8                    pybabel                 rst2s5.py               viewer.py
django-admin.py         iptest                  jupyter-notebook        pilconvert.py           pygmentize              rst2xetex.py            waitress-serve

したがって、virtualenv を入力which pythonすると、chacha_dabang: を指す必要があります/Users/Chois/.pyenv/versions/chacha_dabang/bin/python

どうすれば修正できますか?

4

2 に答える 2

0

PYTHONPATHで使用されるを変更するにはvirtualenv、次の行を virtualenv のbin/activateファイルに追加する必要があります。

`export PYTHONPATH="/correct_path/"


だからあなたの場合はそうあるべきですexport PYTHONPATH="/Users/Chois/.pyenv/versions/chacha_dabang/bin/python"

于 2016-08-19T09:17:41.557 に答える