bash : mkvirtualenv : 명령을 찾을 수 없습니다.
Doug Hellman의 virtualenvwrapper
게시물 에 대한 지침을 따른 후에도 여전히 테스트 환경을 시작할 수 없습니다.
[mpenning@tsunami ~]$ mkvirtualenv test
-bash: mkvirtualenv: command not found
[mpenning@tsunami ~]$
.NET에없는 것을 사용 WORKON_HOME
하고 있다는 점에 유의해야합니다 $HOME
. 설치 문서에/usr/local/bin/virtualenvwrapper.sh
표시된대로 찾으려고 했지만 존재하지 않습니다.virtualenvwrapper
이것이 중요하다면 CentOS 6과 python 2.6.6을 실행하고 있습니다.
# File: ~/.bash_profile
# ...
export WORKON_HOME="/opt/virtual_env/"
source "/opt/virtual_env/bin/virtualenvwrapper_bashrc"
해결 방법 1 :
어떤 이유로, virtualenvwrapper.sh
설치 /usr/bin/virtualenvwrapper.sh
대신에 아래의, /usr/local/bin
.
내 .bash_profile
작품 에서 다음 은 ...
source "/usr/bin/virtualenvwrapper.sh"
export WORKON_HOME="/opt/virtual_env/"
내 설치가 소싱없이 잘 작동하는 것 같습니다. virtualenvwrapper_bashrc
솔루션 2 :
아래에 언급 한 바와 같이 다른 방법으로는 기회를 활용할 수있는 virtualenvwrapper.sh
쉘의 이미를 PATH
단지를 발행source `which virtualenvwrapper.sh`
시험:
source `which virtualenvwrapper.sh`
백틱은 명령 대체입니다. 프로그램이 출력하는 모든 것을 가져 와서 표현식에 넣습니다. 이 경우 "which"는 virtualenvwrapper.sh를 찾기 위해 $ PATH를 확인하고 경로를 출력합니다. 그런 다음 '소스'를 통해 쉘에서 스크립트를 읽습니다.
셸을 다시 시작할 때마다이 작업이 수행되도록하려면 먼저 "which"명령에서 출력을 가져온 다음 다음과 같이 "source"줄을 셸에 넣는 것이 좋습니다.
echo "source /path/to/virtualenvwrapper.sh" >> ~/.profile
^ 이것은 쉘에 따라 약간 다를 수 있습니다. 또한, 하나의>를 사용하지 않도록주의하십시오. 이것은 ~ / .profile을 자르기 때문입니다. : -o
파이썬 2.7.5를 사용하는 OS X 10.9.1에서 동일한 문제가 발생했습니다. 어떤 문제 WORKON_HOME
나를 위해,하지만 난 수동으로 추가해야하지 않았다 source "/usr/local/bin/virtualenvwrapper.sh"
에 ~/.bash_profile
(또는 ~/.bashrc
I의 실행 된 후 유닉스에서)pip install virtualenvwrapper
이 명령을 실행하기위한 전제 조건-
1) PIP (재귀 적 약어 P IP I nstall P ython)를 설치하고 파이썬으로 작성된 소프트웨어 패키지를 관리하는 데 사용되는 패키지 관리 시스템입니다. Python Package Index (PyPI)에서 많은 패키지를 찾을 수 있습니다.
sudo apt-get install python-pip
2) 가상 환경을 설치합니다. 가상 환경을 만들고 서로 격리 된 여러 프로젝트의 패키지 및 종속성을 설치하는 데 사용됩니다.
sudo pip install virtualenv
3) 가상 환경 래퍼 설치 가상 환경 래퍼 정보
sudo pip install virtualenvwrapper
필수 구성 요소 를 설치 한 후에 는 가상 환경을 만들기 위해 가상 환경 래퍼를 실행해야합니다. 다음은 단계입니다.
1) 경로 변수에 가상 환경 디렉토리 설정- export WORKON_HOME=(directory you need to save envs)
2) source /usr/local/bin/virtualenvwrapper.sh -p $WORKON_HOME
@Mike에서 언급했듯이 'virtualenvwrapper.sh'소스이거나 which virtualenvwrapper.sh
virtualenvwrapper.sh 파일을 찾는 데 사용할 수 있습니다.
새 셸을 열 때마다 위의 명령을 실행하지 않으려면 ~ / .bashrc에 두 줄 위에 두는 것이 가장 좋습니다. mkvirtualenv를 사용하여 환경을 만드는 데 필요한 전부입니다.
유의할 점-
- Ubuntu에서는 virtualenv 및 virtualenvwrapper를 루트로 설치해야 할 수 있습니다. 위의 명령 앞에 sudo를 붙이기 만하면됩니다.
- Depending on the process used to install virtualenv, the path to virtualenvwrapper.sh may vary. Find the appropriate path by running $ find /usr -name virtualenvwrapper.sh. Adjust the line in your .bash_profile or .bashrc script accordingly.
Since I just went though a drag, I'll try to write the answer I'd have wished for two hours ago. This is for people who don't just want the copy&paste solution
First: Do you wonder why copying and pasting paths works for some people while it doesn't work for others?** The main reason, solutions differ are different python versions, 2.x or 3.x. There are actually distinct versions of virtualenv and virtualenvwrapper that work with either python 2 or 3. If you are on python 2 install like so:
sudo pip install virutalenv
sudo pip install virtualenvwrapper
If you are planning to use python 3 install the related python 3 versions
sudo pip3 install virtualenv
sudo pip3 install virtualenvwrapper
You've successfully installed the packages for your python version and are all set, right? Well, try it. Type workon
into your terminal. Your terminal will not be able to find the command (workon
is a command of virtualenvwrapper). Of course it won't. Workon
is an executable that will only be available to you once you load/source the file virtualenvwrapper.sh
. But the official installation guide has you covered on this one, right?. Just open your .bash_profile and insert the following, it says in the documentation:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
Especially the command source /usr/local/bin/virtualenvwrapper.sh
seems helpful since the command seems to load/source the desired file virtualenvwrapper.sh
that contains all the commands you want to work with like workon
and mkvirtualenv
. But yeah, no. When following the official installation guide, you are very likely to receive the error from the initial post: mkvirtualenv: command not found
. Still no command is being found and you are still frustrated. So whats the problem here? The problem is that virtualenvwrapper.sh is not were you are looking for it right now. Short reminder ... you are looking here:
source /usr/local/bin/virtualenvwrapper.sh
But there is a pretty straight forward way to finding the desired file. Just type
which virtualenvwrapper
to your terminal. This will search your PATH for the file, since it is very likely to be in some folder that is included in the PATH of your system.
If your system is very exotic, the desired file will hide outside of a PATH folder. In that case you can find the path to virtalenvwrapper.sh
with the shell command find / -name virtualenvwrapper.sh
Your result may look something like this: /Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh
Congratulations. You have found your missing file!
. Now all you have to do is changing one command in your .bash_profile. Just change:
source "/usr/local/bin/virtualenvwrapper.sh"
to:
"/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh"
Congratulations. Virtualenvwrapper does now work on your system. But you can do one more thing to enhance your solution. If you've found the file virtualenvwrapper.sh
with the command which virtualenvwrapper.sh
you know that it is inside of a folder of the PATH. So if you just write the filename, your file system will assume the file is inside of a PATH folder. So you you don't have to write out the full path. Just type:
source "virtualenvwrapper.sh"
Thats it. You are no longer frustrated. You have solved your problem. Hopefully.
Use this procedure to create virtual env in ubuntu
step 1 Install pip
sudo apt-get install python-pip
step 2 Install virtualenv
sudo pip install virtualenv
step3 Create a dir to store your virtualenvs (I use ~/.virtualenvs)
mkdir ~/.virtualenvs
or user this command to install specific version of python in env
virtualenv -p /usr/bin/python3.6 venv
setp 4
sudo pip install virtualenvwrapper
step 5
sudo nano ~/.bashrc
step 6 Add this two line code at the end of the bashrc file
export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
step 7 open new terminal (recommended)
step 8 Create a new virtualenv
mkvirtualenv myawesomeproject
step 9 To load or switch between virtualenvs, use the workon command:
workon myawesomeproject
step 10 to exit your new virtualenv, use
deactivate
and make sure using pip vs pip3
OR follow below steps to install virtual environment in python project
cd ~/demos
install env
python3 -m venv my-project-env
Next, activate your virtual environment using the following command:
source my-project-env/bin/activate
On Windows 7 and Git Bash this helps me:
- Create a ~/.bashrc file (under your user home folder)
- Add line export WORKON_HOME=$HOME/.virtualenvs (you must create this folder if it doesn't exist)
- Add line source "C:\Program Files (x86)\Python36-32\Scripts\virtualenvwrapper.sh" (change path for your virtualenvwrapper.sh)
Restart your git bash and mkvirtualenv command now will work nicely.
Using Git Bash on Windows 10 and Python36 for Windows I found the virtualenvwrapper.sh in a slightly different place and running this resolved the issue
source virtualenvwrapper.sh
/c/users/[myUserName]/AppData/Local/Programs/Python36/Scripts
Solved my issue in Ubuntu 14.04 OS with python 2.7.6, by adding below two lines into ~/.bash_profile (or ~/.bashrc in unix) files.
source "/usr/local/bin/virtualenvwrapper.sh"
export WORKON_HOME="/opt/virtual_env/"
And then executing both these lines onto the terminal.
On Windows 10, to create the virtual environment, I replace "pip mkvirtualenv myproject" by "mkvirtualenv myproject" and that works well.
참고URL : https://stackoverflow.com/questions/13855463/bash-mkvirtualenv-command-not-found
'IT story' 카테고리의 다른 글
REST HATEOAS (성숙도 레벨 3)는 얼마나 유용하고 중요합니까? (0) | 2020.09.04 |
---|---|
Xcode를 완전히 제거하고 모든 설정을 지우는 방법 (0) | 2020.09.04 |
HTML5 날짜 선택기에 대한 스타일 옵션이 있습니까? (0) | 2020.09.04 |
앱 구성, angular.js의 사용자 지정 공급자 내에서 $ http 사용 (0) | 2020.09.04 |
EC2 Elastic Load Balancer를 HTTP에서 HTTPS로 리디렉션 (0) | 2020.09.04 |