Skip to content

python version/ sudo pip/ pip install 문제 #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
minheeseo opened this issue Jan 18, 2018 · 8 comments
Closed

python version/ sudo pip/ pip install 문제 #163

minheeseo opened this issue Jan 18, 2018 · 8 comments
Labels
Python 파이썬 관련 백서

Comments

@minheeseo
Copy link

안녕하세요,

파이손 package installation에 문제가 생겨서 여기에 올립니다.
최근에 랩탑을 바꿨는데, 파이손3을 잘못 설치 한건지 pip install 명령을 할때마다

Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/c3/znjsw9191xn_m42yb54400zh0000gn/T/pip-build-eX1ndT/nltk/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /var/folders/c3/znjsw9191xn_m42yb54400zh0000gn/T/pip-cpkcEL-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/c3/znjsw9191xn_m42yb54400zh0000gn/T/pip-build-eX1ndT/nltk/

이란 에러가 뜨는데, 도통 찾아봐도 해결 방법을 잘 모르겠네요.

심지어 같은 python script가 python file.py때는 실행이 잘 되는데 python3 file.py때는 package가 없다는 에러문구가 뜨면서 실행이 되지 않습니다. path를 제가 잘못 건드린것 같은데 어떻게 해결하는게 가장 좋을까요?

또 sudo pip이랑 pip 의 차이는 정확히 어떻게 되는지 궁금합니다. sudo pip intall 을 치면

The directory '/Users/minheeseo/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/minheeseo/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

이런 경고문이 뜨는데, 저 혼자 사용하고 있는 랩탑인데 왜 이런 문구가 뜰까요?

@azaraks
Copy link

azaraks commented Jan 18, 2018

python3 package는 pip3로 설치했나요?
sudo가 어떤 명령인지는 man sudo 해보시면 알 수 있습니다.

@minheeseo
Copy link
Author

@azaraks2님, 빨리 답변해주셔서 감사합니다.

시간이 조금 되서 pip3 명령어를 썼는지는 확실하게 기억이 나지 않습니다만 그런 것 같아요. 제가 이루고 싶은건 패키지를 설치할때나 스크립트를 돌릴때 python2.7버전에서도 python3버전에서도 성공적으로 돌아가게 하는 건데, 어떻게 하면 될까요? python3에 따로 패키지를 설치해야하면 어떤 명령어를 써야 python2.7가 아니라 python3에 설치를 하게 하지요?

그리고 두번째 질문은 제가 설명을 잘 못했네요. sudo 명령어 자체는 이해가되지만 제가 혼자쓰는 랩탑인데 왜 sudo pip을 써야하는지 이해가 잘 안되서 질문 드립니다.

@dhchoi82
Copy link

혹시 어떤 운영체제를 쓰시나요?

@minheeseo
Copy link
Author

@dhchoi82 Mac OS 쓰고 있습니다~

@azaraks
Copy link

azaraks commented Jan 19, 2018

python2와 python3로 이중작업을 하시는 건가요?
설치용 쉘 스크립트로 판단할 수 있지만 하나만 선택하는 것이 더 나아 보입니다.

시스템에 영향을 주는 명령을 구분하고 함부로 실행되지 않도록 하기 위해, superuser만이 실행할 수 있도록 되어있습니다. 다른 *nix도 마찬가지입니다.

@dhchoi82
Copy link

dhchoi82 commented Jan 19, 2018

저는 우분투와 윈도우만 쓰고 있어서 Mac OS에서 테스트 해볼만한 방법이 없네요.

우분투에 기본으로 설치된 python2와는 별도로 python3를 설치해서 쓰고 있는데,
python 명령어는 기본 설치된 그대로 python2에 심볼릭 링크로 연결되어 있습니다.
image

예전에 저걸 python3로 바꿨더니, 의존성 있는 프로그램들이 제대로 동작을 안하더라구요.
대신 python3로 짠 스크립트에는 맨 첫줄에 #!/usr/bin/python3를 적어둡니다.
이걸 Shebang이라고 하는 모양인데, 혹시 맥에서도 동작하는지는 모르겠습니다.
https://docs.python.org/3/using/windows.html#shebang-lines

혹시 공식문서의 설명이 도움이 되실런지 몰라 주소 적어둡니다.
https://docs.python.org/3/using/mac.html

unix와 같이 사용자 계정이 나뉘어 있는 시스템에서는 실사용자가 1명이냐의 여부와는 상관없이 사용자의 권한을 제한합니다. 제한된 시스템의 중요한 부분에 접근하기 위해서는 권한을 가진 root와 같은 사용자로 로그인하거나 sudo와 같은 방법으로 임시로 권한을 얻어와야 합니다. 권한을 얻어오지 못하면, 에러가 발생합니다.

맥 os에서 python 2와 3를 설치하는 방법을 검색하면 나오는 stackoverflow의 문답이 있어 이것도 주소 적어 둡니다.
https://stackoverflow.com/questions/18671253/how-can-i-use-homebrew-to-install-both-python-2-and-3-on-mac

@minheeseo
Copy link
Author

@azaraks2 도움주셔서 감사합니다.

@dhchoi82 많이 배우고 갑니다. 문서들 잘 읽어보겠습니다 ^^

@davidkwak
Copy link
Collaborator

며칠 지난 질문이긴합니다만...

  1. pip 에러는 nltk 패키지 설치에 문제가 있다는 에러입니다. 해당 패키지가 설치되어 있다면 삭제하시고 다시 설치해보시고, 설치되어 있지 않다면 pip이 아닌 다른 경로로 설치해보세요

  2. 혼자 쓰는 컴퓨터라고하더라도 일반 사용자 권한과 관리자 권한은 구분되어 있습니다. windows에서도 무슨 프로그램을 설치하거나 할때 오른쪽 클릭해서 관리자 권한으로 실행하라던지 하는 경우가 종종 있습니다. 비슷한 맥락인듯 합니다.

sudo 로 pip을 하게되면 pip을 하는동안 관리자권한을 갖게되고 현재 사용자인 minheeseo 가 아닌 root로 설치가 됩니다. 해당 명령으로 생성된 파일의 소유자는 minheeseo가 아닌 root가 됩니다.

  1. 심지어 같은 python script가 python file.py때는 실행이 잘 되는데 python3 file.py때는 package가 없다는 에러문구가 뜨면서 실행이 되지 않습니다. path를 제가 잘못 건드린것 같은데 어떻게 해결하는게 가장 좋을까요?

터미널 상에서 "which python" 을 입력하시면 현재의 python 실행파일의 경로를 알려줍니다. 아마 /usr/bin/python 이실텐데 python3를 설치하셨다면 설치하신 python3의 심볼릭링크를 같은 디렉터리에 생성해주시면 python3 라고 치면 해당 파일이 실행됩니다.

만일 python3를 설치하지 않으셨다면 anaconda 같은 패키지를 까시거나 brew install python3로 설치하세요

@happydeveloper happydeveloper added the Python 파이썬 관련 label Jan 23, 2018
@happydeveloper happydeveloper added this to the 코딩야학 3기 milestone Jan 23, 2018
@blackdew blackdew closed this as completed Aug 9, 2018
@blackdew blackdew closed this as completed Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Python 파이썬 관련 백서
Projects
None yet
Development

No branches or pull requests

6 participants