virtualenvwrapper仮想環境エラーという名前のモジュールがありません



No Module Named Virtualenvwrapper Virtual Environment Error



仮想環境をインストールするコマンド

sudo pip install virtualenv sudo pip install virtualenvwrapper #1, create a directory to store the virtual environment Mkdir $HOME/.virtualenvs # $HOME represents the home directory for saving the directory generated by the virtual environment #2, open the ~/.bashrc file and add the following: Export WORKON_HOME=$HOME/.virtualenvs # Import the directory saved by the virtual environment Source /usr/local/bin/virtualenvwrapper.sh # Add the path to the command # 3, running Source ~/.bashrc # Let the command take effect

次に、以下のエラーが発生した場合は、Pythonインタープリターへのパスが〜/ .bashrcファイルに設定されていないことが原因です。

/usr/bin/python: No module named virtualenvwrapper virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenvwrapper has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.

次のコードを挿入する必要があります

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv

次に、コマンドを再度実行します

source ~/.bashrc

次の出力が表示された場合

virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/initialize virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/premkvirtualenv virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postmkvirtualenv virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/prermvirtualenv virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postrmvirtualenv virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/predeactivate virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postdeactivate virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/preactivate virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postactivate virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/get_env_details virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/premkproject virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postmkproject

仮想環境をインポートするコマンドは正常に実行され、通常どおり使用できます。