Development Tip

Pipenv : 명령을 찾을 수 없음

yourdevel 2020. 11. 12. 20:28
반응형

Pipenv : 명령을 찾을 수 없음


저는 Python 개발이 처음이고 pipenv를 사용하려고합니다. pip install pipenv성공적으로 실행 된 명령 을 실행했습니다.

...
Successfully built pipenv pathlib shutilwhich pythonz-bd virtualenv-clone
Installing collected packages: virtualenv, pathlib, shutilwhich, backports.shutil-get-terminal-size, pythonz-bd, virtualenv-clone, pew, first, six, click, pip-tools, certifi, chardet, idna, urllib3, requests, pipenv
...

그러나 pipenv install새 루트 프로젝트 디렉터리에서 명령 실행 하면 다음 메시지가 나타납니다 -bash: pipenv: command not found.. .bashrc를 수정해야한다고 생각하지만 파일에 무엇을 추가해야하는지 또는 수정이 필요한지 확실하지 않습니다.


이는 전체적으로 (시스템 전체) 설치하지 않기 때문에 발생합니다. 에서 사용할 수 있으려면 path다음과 같이을 사용하여 설치해야합니다 sudo.

$ sudo pip install pipenv

이것은 나를 위해 수정했습니다.

sudo -H pip install -U pipenv

사용자 설치를 완료 한 경우 PATH변수에 올바른 폴더를 추가해야 합니다.

PYTHON_BIN_PATH="$(python3 -m site --user-base)/bin"
PATH="$PATH:$PYTHON_BIN_PATH"

pipenv의 설치 지침을 참조하십시오.


pipenvMac OS X 10.13 High Seirra에서 동일한 문제가 발생하고 다른 Mac이 잘 작동합니다. 저는 Heroku를 사용하여 Django 서버를 배포합니다. 일부는 2.7, 일부는 3.6입니다. 따라서 2.7과 3.6이 모두 필요합니다. HomeBrew가 Python을 설치할 때 python포인트는 원래 2.7, python3포인트는 3.6을 유지합니다.

문제는 $ pip install pipenv. / usr / local / bin을 확인했는데 pipenv가 없습니다. 그래서 전체 제거를 시도했습니다.

$ pip uninstall pipenv

Cannot uninstall requirement pipenv, not installed
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ pip3 uninstall pipenv
Skipping pipenv as it is not installed.

그런 다음 지금 다시 설치하고 작동합니다.

$ pip3 install pipenv
Collecting pipenv

나는 이것을 시도했다 :

python -m pipenv # for python2

python3 -m pipenv # for python3

이것이 당신을 도울 수 있기를 바랍니다.


OSX 얘들 아, 여기!

@charlax가 대답했듯이 (나에게 가장 좋은 방법) PATH를 설정하는 더 동적 인 명령을 사용할 수 있습니다. mac 사용자의 경우 buuut 작동하지 않을 수 있습니다 . 때로는 사이트에서 가져온 USER_BASE 경로가 잘못되었으므로 위치를 찾아야합니다. 파이썬 설치입니다.

$ which python3
/usr/local/bin/python3.6

심볼릭 링크를 얻은 다음 소스의 심볼릭 링크를 찾아야합니다.

$ ls -la /usr/local/bin/python3.6
  lrwxr-xr-x  1 root  wheel  71 Mar 14 17:56 /usr/local/bin/python3.6 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6

(이것은 ../../../루트를 의미합니다)

그래서 파이썬 경로 ( /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6) 를 찾았다면 다음과 같이 ~ / .bashrc를 입력하면됩니다.

export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.6/bin"


Python이 패키지를 저장하는 위치

설치할 명령으로 이동하기 전에 Python 패키지를 설치pipenv 하는 위치를 이해하는 것이 좋습니다.pip

전역 사이트 패키지 는 Python이 시스템의 모든 사용자와 모든 Python 응용 프로그램에서 사용할 수있는 패키지를 설치하는 곳입니다. 다음 명령으로 글로벌 사이트 패키지를 확인할 수 있습니다.

python -m site

예를 들어 Python 3.7이 설치된 Linux에서 경로는 일반적으로

/usr/lib/python3.7/dist-packages/setuptools

사용자 사이트 패키지 는 Python이 사용자 에게만 제공되는 패키지를 설치하는 곳입니다. 그러나 패키지는 생성 한 모든 Python 프로젝트에 계속 표시됩니다. 당신은 경로를 얻을 수 있습니다

python -m site --user-base

Python 3.7이 설치된 Linux에서 경로는 일반적으로

~/.local/lib/python3.7/site-packages

Python 3.x 사용

대부분의 Linux 및 기타 Unices에서 일반적으로 Python 2와 Python 3은 나란히 설치됩니다. 기본 Python 3 실행 파일은 거의 항상 python3입니다. pipLinux 배포에 따라 다음 중 하나로 사용할 수 있습니다.

pip3
python3-pip
python36-pip
python3.6-pip

리눅스

pip와 함께 사용하지 마십시오 sudo! 예, Python 패키지를 설치하는 가장 편리한 방법이며 실행 파일은에서 사용할 수 /usr/local/bin/pipenv있지만 특정 패키지는 항상 모든 사용자와 생성 한 모든 Python 프로젝트에 표시됩니다. 대신 사용자 별 사이트 패키지를 사용하십시오.--user

pip3 install --user pipenv

pipenv is available at

~/.local/bin/pipenv

macOS

On macOS, Homebrew is the recommended way to install Python. You can easily upgrade Python, install multiple versions of Python and switch between versions using Homebrew.

If you are using Homebrew'ed Python, pip install --user is disabled. The global site-package is located at

/usr/local/lib/python3.y/site-packages

and you can safely install Python packages here. Python 3.y also searches for modules in:

 /Library/Python/3.y/site-packages
 ~/Library/Python/3.y/lib/python/site-packages

Windows

For legacy reasons, Python is installed in C:\Python37. The Python executable is usually named py.exe, and you can run pip with py -m pip.

Global site packages is installed in

C:\Python37\lib\site-packages

Since you don't usually share your Windows devices, it is also OK to install a package globally

py -m pip install pipenv

pipenv is now available at

C:\Python37\Scripts\pipenv.exe

I don't recommend install Python packages in Windows with --user, because the default user site-package directory is in your Windows roaming profile

C:\Users\user\AppData\Roaming\Python\Python37\site-packages 

The roaming profile is used in Terminal Services (Remote Desktop, Citrix, etc) and when you log on / off in a corporate environment. Slow login, logoff and reboot in Windows can be caused by a large roaming profile.


Installing pipenv globally can have an adverse effect by overwriting the global/system-managed pip installation, thus resulting in import errors when trying to run pip.

You can install pipenv at the user level:

pip install --user pipenv

This should install pipenv at a user-level in /home/username/.local so that it does not conflict with the global version of pip. In my case, that still did not work after running the '--user' switch, so I ran the longer 'fix what I screwed up' command once to restore the system managed environment:

sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall

^ found here: Error after upgrading pip: cannot import name 'main'

and then did the following:

mkdir /home/username/.local ... if it doesn't already exist

export PYTHONUSERBASE=/home/username/.local

Make sure the export took effect (bit me once during this process):

echo $PYTHONUSERBASE

Then, I ran the pip install --user pipenv and all was well. I could then run pipenv from the CLI and it did not overwrite the global/system-managed pip module. Of course, this is specific to the user so you want to make sure you install pipenv this way while working as the user you wish to use pipenv.

References:

https://pipenv.readthedocs.io/en/latest/diagnose/#no-module-named-module-name https://pipenv.readthedocs.io/en/latest/install/#pragmatic-installation-of-pipenv https://pip.pypa.io/en/stable/user_guide/#user-installs


You might consider installing pipenv via pipsi.

curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get -pipsi.py | python3
pipsi install pew
pipsi install pipenv

Unfortunately there are some issues with macOS + python3 at the time of writing, see 1, 2. In my case I had to change the bashprompt to #!/Users/einselbst/.local/venvs/pipsi/bin/python


This is fixed for me to:

sudo -H pip install -U pipenv

In some cases of old pip version:

sudo easy_install pip
sudo pip install pipenv

For window users this may be due to conflicting installation with virtualenv. For me it worked when I uninstalled virtualenv and pipenv first, and then install only pipenv.

pip uninstall virtualenv
pip uninstall pipenv
pip install pipenv

Now pipenv install xxx worked for me


After installing pipenv (sudo pip install pipenv), I kept getting the "Command Not Found" error when attempting to run the pipenv shell command.

I finally fixed it with the following code:

pip3 install pipenv
pipenv shell

참고URL : https://stackoverflow.com/questions/46391721/pipenv-command-not-found

반응형