Programming

Virtualenv 명령을 찾을 수 없음

procodes 2020. 6. 8. 21:56
반응형

Virtualenv 명령을 찾을 수 없음


virtualenv다양한 시도에도 불구하고 일을 할 수 없었습니다 . virtualenvMAC OS X에 다음을 사용하여 설치 했습니다.

pip install virtualenv

또한 추가 한 PATH내에 .bash_profile. virtualenv명령 을 실행할 때마다 다음이 반환됩니다.

-bash: virtualenv: command not found

내가 실행할 때마다 pip install virtualenv다음을 반환합니다.

Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

Mac에서는 virtualenv올바르게 설치해야 한다는 것을 알고 있습니다.

/usr/local/bin

virtualenv참에 설치되어있는 /usr/local/bin,하지만 난 실행하려고 할 때마다 virtualenv명령을, 명령을 찾을 수 없습니다. 또한 virtualenv디렉토리 에서 명령 을 실행하려고 시도했지만 /usr/local/bin동일한 결과를 얻습니다.

-bash: virtualenv: command not found

이들은 .bash_profile에 추가 한 PATH입니다.

export PATH=$PATH:/usr/local/bin
export PATH=$PATH:/usr/local/bin/python
export PATH=$PATH:/Library/Framework/Python.framework/Version/2.7/lib/site-packages

이에 대한 해결 방법이 있습니까? 왜 이런 경우입니까?


함께 설치 한 경우

pip install virtualenv

당신은 실행해야합니다

sudo /usr/bin/easy_install virtualenv

에 넣습니다 /usr/local/bin/.

위의 디렉토리는 기본적으로 PATH; 그렇지 않으면 그에 따라 .zshrc(또는. bashrc)를 편집하십시오 .


나는 같은 문제에 직면했으며 이것이 내가 해결 한 방법입니다.

  1. pip를 통해 virtualenv를 루트가 아닌 일반 사용자로 설치했기 때문에 문제가 발생했습니다. pip는 디렉토리에 패키지를 설치했습니다~/.local/lib/pythonX.X/site-packages
  2. pip를 루트 또는 관리자 권한 (sudo)으로 실행하면 패키지가에 설치되었습니다 /usr/lib/pythonX.X/dist-packages. 이 경로는 다를 수 있습니다.
  3. virtualenv 명령은 두 번째 시나리오에서만 인식됩니다.
  4. 따라서 문제를 해결하려면 pip uninstall virtualenv다음을 사용 하여 문제를 해결 한 다음 다시 설치하십시오 sudo pip install virtualenv(또는 루트로 설치).

가장 간단한 대답. 다만:

pip uninstall virtualenv

그리고:

pip install virtualenv

또는 다음과 같이 virtualenv를 설치 sudo했을 수 있습니다.

pip install --user virtualenv

Ubuntu 18.04 LTS에서도 같은 오류가 발생했습니다. 다음 명령이 작동했습니다.

sudo apt-get install python-virtualenv

Mac OS X El Capitan에서도 같은 문제가있었습니다 .

나는이 설치되면 virtualenv있다는처럼 sudo pip3 install virtualenv내가하지 않았다 virtualenv내 명령 줄에서.

다음 단계에 따라이 문제를 해결했습니다.

  1. 이전 설치를 제거하십시오.
  2. virtualenv전화를 걸어 설치 하기 전에 수퍼 유저 계정으로 전환sudo su
  3. virtualenv전화로 설치pip3 install virtualenv
  4. 마지막으로 액세스 할 수 있어야 virtualenv모두에서 usersuper user계정.

당신은 때마다 당신이 실행하는 것이 말했다 pip install당신이 얻을 Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages. 당신이해야 할 일은 다음과 같습니다

  1. 디렉토리 변경 (virtualenv.py가있는 디렉토리로 이동) cd /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
  2. 당신이 할 경우, ls당신은 스크립트가있는 것을 볼 수 있습니다virtualenv.py
  3. 다음과 같이 스크립트를 실행하십시오. python virtualenv.py --distribute /the/path/at/which/you/want/the/new/venv/at theNameOfTheNewVirtualEnv

도움이 되었기를 바랍니다. 저의 조언은 venvs를 더 연구하는 것입니다. 다음은 좋은 리소스입니다. https://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/


문제 파악

--verbose플래그로 설치해보십시오

pip install virtualenv --verbose

출력은 다음과 같습니다

  ..
  Using cached virtualenv-15.1.0-py2.py3-none-any.whl
  Downloading from URL https://pypi.python.org/packages/6f/86/3dc328ee7b1a6419ebfac7896d882fba83c48e3561d22ddddf38294d3e83/virtualenv-15.1.0-py2.py3-none-any.whl#md5=aa7e5b86cc8cdb99794c4b99e8d670f3 (from https://pypi.python.org/simple/virtualenv/)
Installing collected packages: virtualenv

  changing mode of /home/manos/.local/bin/virtualenv to 755
Successfully installed virtualenv-15.1.0
Cleaning up...

출력에서 우리는 그것이 설치되어 있음을 알 수 /home/manos/.local/bin/virtualenv있으므로 PATH에 포함되어 있는지 확인하십시오.

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

필자의 경우 /home/manos/.local/bin완전히 누락 된 것을 분명히 알 수 있으므로 쉘이 프로그램을 찾을 수 없습니다.

솔루션

우리는 이것을 여러 가지 방법으로 해결할 수 있습니다 :

  1. pip 옵션을 사용하여 (권장하지 않음) 특정 디렉토리에 직접 설치할 수 있습니다.
  2. 적절한 심볼릭 링크를 만들 /usr/local/bin거나 비슷하게 만드십시오 .
  3. /home/manos/.local/binPATH에 추가하십시오 .
  4. 직접 설치하려면 sudo로 설치 /usr/local/bin

The two last options are probably the most sensible. The last solution is the simplest so therefore I will just show solution 3.

Add this to ~/.profile:

PATH="$PATH:$HOME/.local/bin"

Logout out and in again and it should work.


I had troubles because I used apt to install python-virtualenv package. To get it working I had to remove this package with apt-get remove python-virtualenv and install it with pip install virtualenv.


In my case, I ran pip show virtualenv to get the information about virtualenv package. I will look similar to this and will also show location of the package:

user@machine:~$ pip show virtualenv
Name: virtualenv
Version: 16.2.0
Summary: Virtual Python Environment builder
Home-page: https://virtualenv.pypa.io/
Author: Ian Bicking
Author-email: ianb@colorstudy.com
License: MIT
Location: /home/user/.local/lib/python3.6/site-packages
Requires: setuptools

From that grab the part of location up to the .local part, which in this case is /home/user/.local/. You can find virtualenv command under /home/user/.local/bin/virtualenv.

You can then run commands like /home/user/.local/bin/virtualenv newvirtualenv.


I think your problem can be solved using a simple symbolic link, but you are creating the symbolic link to the wrong file. As far as I know virtualenv is installed to /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenv, (you can change the numbers for your Python version) so the command for creating the symbolic link should be:

ln -s /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenv /usr/local/bin/virtualenv

Same problem: So I just did pip uninstall virtualenv Then pip install virtualenv

pip install virtualenv --user

Collecting virtualenv Using cached https://files.pythonhosted.org/packages/b6/30/96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5/virtualenv-16.0.0-py2.py3-none-any.whl Installing collected packages: virtualenv

Then I got this :

The script virtualenv is installed in '/Users/brahim/Library/Python/2.7/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

which clearly says where it is installed and what to do to get it


On ubuntu 18.4 on AWS installation with pip don't work correctly. Using apt-get install the problem was solved for me.

sudo apt-get install python-virtualenv

and to check

virtualenv --version

Ensure that virtualenv is executable.

If virtualenv is not found, running the full path (/usr/local/bin/virtualenv) should work.


If you're using Linux, open your terminal and type virtualenv halfway and autocomplete with tab key. If there's no auto-completion install virtualenv on your system by running:

mycomp$sudo apt-get install virtualenv
//if you're already super user.
mycomp#apt-get install virtualenv

You can now navigate to where you want to create your project and do:

myprj$pip3 install virtualenv    
//to install python 3.5 and above  
myprj$virtualenv venv --python=python3.5  
//to activate virtualenv  
(venv)myprj$source venv/bin/activate  
(venv)myprj$deactivate

apt update
apt upgrade
apt install ufw python virtualenv git unzip pv

3 commands and everything working!


python3 -m virtualenv virtualenv_name

python -m virtualenv virtualenv_name


Follow these basic steps to setup the virtual env

sudo pip install virtualenv virtualenvwrapper
sudo rm -rf ~/get-pip.py ~/.cache/pip

we need to update our ~/.bashrc

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

The ~/.bashrc file is simply a shell script that Bash runs whenever you launch a new terminal. You normally use this file to set various configurations. In this case, we are setting an environment variable called WORKON_HOME to point to the directory where our Python virtual environments live. We then load any necessary configurations from virtualenvwrapper .

To update your ~/.bashrc file simply use a standard text editor, nano is likely the easiest to operate. A more simple solution is to use the cat command and avoid editors entirely:

echo -e "\n# virtualenv and virtualenvwrapper" >> ~/.bashrc
echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.bashrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc

After editing our ~/.bashrc file, we need to reload the changes:

source ~/.bashrc

Now that we have installed virtualenv and virtualenvwrapper , the next step is to actually create the Python virtual environment — we do this using the mkvirtualenv command.

mkvirtualenv YOURENV

sudo apt-get install python-virtualenv

참고URL : https://stackoverflow.com/questions/31133050/virtualenv-command-not-found

반응형