2017-03-28 20 views
14

私は、python 2.7 + virtualenvバージョン1.10.1を使ってmyprojectプロジェクトを実行しています。他のプロジェクトの要件のため、私はPythonの他のバージョン(Python 3.5)とDjango 1.9で作業する必要があります。これは私のユーザーディレクトリにPythonをインストールしました。また、私はdowloadedと私のユーザーディレクトリにvirtualenv(バージョン - 15.1.0)をインストールしました。 しかし、私は仮想のenv私は以下のエラーpython3で仮想envを作成するには

python virtualenv/virtualenv.py myproject 
を取得していますを作成しようとしていますたび
Using base prefix '/home/myuser/python3' 
New python executable in /home/mount/myuser/project_python3/myproject/bin/python 
ERROR: The executable /home/mount/myuser/project_python3/myproject/bin/python is not functioning 
ERROR: It thinks sys.prefix is '/home/myuser/python3' (should be '/home/mount/myuser/project_python3/myproject') 
ERROR: virtualenv is not compatible with this system or executable 

誰もが、私はその組み込みと、すでに船この

+1

実行時に使用しているPythonが不明です'python virtualenv/virtualenv.py myproject'を実行します。 'python'はあなたのシステムのPython(2.7)かローカルのPython(3.5)ですか? – Chris

+1

virtualenv version - 15.1.0をインストールするために正しいpip(pip3)を使用しましたか? –

+0

私はいつでも[これらのドキュメント](http://python-guide-pt-br.readthedocs.io/en/latest/dev/virtualenvs/)が役立っています。 – blacksite

答えて

28

pyvenvモジュールは廃止予定です。代わりに、次のワンライナーを使用します。

python3 -m venv <myenvname> 

これは、Pythonコミュニティで仮想環境を作成するためのrecommended wayです。

5

のPythonで間違ってやっている何を言うことができます」バージョン3.3以降はvenvと呼ばれています。 Python 3.3以降用のスクリプトをインストールまたはダウンロードする必要はありません。インストールが「virtualenvの」作成の世話をする必要がありますpyvenvコマンドを提供

https://docs.python.org/3/library/venv.html

チェック。引数は従来のvirtualenvプロジェクトと似ています。

$ pyvenv --help 
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear] 
      [--upgrade] [--without-pip] 
      ENV_DIR [ENV_DIR ...] 

Creates virtual Python environments in one or more target directories. 

positional arguments: 
    ENV_DIR    A directory to create the environment in. 

optional arguments: 
    -h, --help   show this help message and exit 
    --system-site-packages 
         Give the virtual environment access to the system 
         site-packages dir. 
    --symlinks   Try to use symlinks rather than copies, when symlinks 
         are not the default for the platform. 
    --copies    Try to use copies rather than symlinks, even when 
         symlinks are the default for the platform. 
    --clear    Delete the contents of the environment directory if it 
         already exists, before environment creation. 
    --upgrade    Upgrade the environment directory to use this version 
         of Python, assuming Python has been upgraded in-place. 
    --without-pip   Skips installing or upgrading pip in the virtual 
         environment (pip is bootstrapped by default) 

Once an environment has been created, you may wish to activate it, e.g. by 
sourcing an activate script in its bin directory. 
+4

このスクリプトはPython 3.6以降では推奨されていませんが、モジュールはまだ存在します。推奨される使用法は次のとおりです: '' python3 -m venv '' –

+0

@ user73657私はpython 3.5を使用しています。しかし、私がコマンドpyenvを実行しても、そのコマンドが見つかりませんでした。 – Anish

+0

@ user73657 pyenvは3.5.3で利用できません – Anish

-1

virtualenvwrapperをvirtualenvの上にインストールすると、単純化することができます。 ステップで簡単にインストールするには、ブログに従ってください:virtualenvwrapper

のステップは、それを作成するために:

  1. mkvirtualenv -pは/ usr/binに/のpython3使用
  2. インストールパッケージ - パッケージ名
  3. workonをインストールPIP - deactivate - viirtualenvを無効にする
+1

'virtualenv'の周りにラッパーを追加すると' virtualenv'自体がうまくいかない場合はどのように役立ちますか? – Chris

+0

これは繰り返しの回答です。これも間違った答えです。 virtualenvは廃止予定です。これはvirtualenvのラッパーです –

関連する問題