루트 액세스없이 파이썬 모듈을 설치하는 방법은 무엇입니까?
나는 몇 가지 대학 수업을 받고 있으며 '교육용 계정'을 받았는데, 이는 일을하기 위해 ssh 할 수있는 학교 계정입니다. 컴퓨터에서 계산 집약적 인 Numpy, matplotlib, scipy 코드를 실행하고 싶지만 시스템 관리자가 아니기 때문에 이러한 모듈을 설치할 수 없습니다.
설치는 어떻게합니까?
대부분의 상황에서 가장 좋은 해결책은 다음을 실행하여 소위 "사용자 사이트"위치 (자세한 내용은 PEP 참조)에 의존 하는 것입니다.
pip install --user package_name
아래는 내 원래의 대답에서보다 "수동적 인"방법입니다. 위의 해결책이 효과가 있다면 그것을 읽을 필요가 없습니다.
easy_install을 사용하면 다음을 수행 할 수 있습니다.
easy_install --prefix=$HOME/local package_name
어느 곳에 설치
$HOME/local/lib/pythonX.Y/site-packages
( 'local'폴더는 많은 사람들이 사용하는 일반적인 이름이지만 물론 쓰기 권한이있는 폴더를 지정할 수도 있습니다).
수동으로 만들어야합니다
$HOME/local/lib/pythonX.Y/site-packages
PYTHONPATH
환경 변수에 추가하십시오 (그렇지 않으면 easy_install이 불평합니다-btw는 위의 명령을 한 번 실행하여 XY의 올바른 값을 찾습니다).
를 사용하지 않는 경우 easy_install
접두사 옵션을 찾으십시오. 대부분의 설치 스크립트에서이를 지정할 수 있습니다.
pip를 사용하면 다음을 사용할 수 있습니다.
pip install --install-option="--prefix=$HOME/local" package_name
액세스하거나 설치할 수있는 권한이 easy_install
없습니까?
그런 다음, 파이썬 virtualenv
( https://pypi.python.org/pypi/virtualenv )을 작성 하고이 가상 환경에서 패키지를 설치할 수 있습니다.
셸에서 4 개의 명령을 실행하면 충분합니다 (XXX의 경우 16.1.0과 같은 현재 릴리스 삽입).
$ curl --location --output virtualenv-X.X.X.tar.gz https://github.com/pypa/virtualenv/tarball/X.X.X
$ tar xvfz virtualenv-X.X.X.tar.gz
$ python pypa-virtualenv-YYYYYY/src/virtualenv.py my_new_env
$ . my_new_env/bin/activate
(my_new_env)$ pip install package_name
출처 및 추가 정보 : https://virtualenv.pypa.io/en/latest/installation/
root 액세스 없이도 easy_install을 실행하여 홈 디렉토리에 Python 패키지를 설치할 수 있습니다. $ HOME / .local 또는 $ HOME / Library / Python / 2.7 / bin과 같이 기본적으로 PYTHONPATH에 포함되는 site.USER_BASE를 사용하여이를 수행하는 표준 방법이 있습니다.
이렇게하려면 홈 디렉토리에 .pydistutils.cfg를 작성하십시오.
cat > $HOME/.pydistutils.cfg <<EOF
[install]
user=1
EOF
이제 루트 권한없이 easy_install을 실행할 수 있습니다.
easy_install boto
또는 루트 액세스없이 pip를 실행할 수도 있습니다.
pip install boto
이것은 나를 위해 작동합니다.
Wesley Tanaka의 블로그 출처 : http://wtanaka.com/node/8095
If you have to use a distutils setup.py
script, there are some commandline options for forcing an installation destination. See http://docs.python.org/install/index.html#alternate-installation. If this problem repeats, you can setup a distutils configuration file, see http://docs.python.org/install/index.html#inst-config-files.
Setting the PYTHONPATH variable is described in tihos post.
Important question. The server I use (Ubuntu 12.04) had easy_install3
but not pip3
. This is how I installed Pip and then other packages to my home folder
Asked admin to install Ubuntu package
python3-setuptools
Installed pip
Like this:
easy_install3 --prefix=$HOME/.local pip
mkdir -p $HOME/.local/lib/python3.2/site-packages
easy_install3 --prefix=$HOME/.local pip
- Add Pip (and other Python apps to path)
Like this:
PATH="$HOME/.local/bin:$PATH"
echo PATH="$HOME/.local/bin:$PATH" > $HOME/.profile
- Install Python package
like this
pip3 install --user httpie
# test httpie package
http httpbin.org
I use JuJu which basically allows to have a really tiny linux distribution (containing just the package manager) inside your $HOME/.juju directory.
It allows to have your custom system inside the home directory accessible via proot and, therefore, you can install any packages without root privileges. It will run properly to all the major linux distributions, the only limitation is that JuJu can run on linux kernel with minimum reccomended version 2.6.32.
For instance, after installed JuJu to install pip just type the following:
$>juju -f
(juju)$> pacman -S python-pip
(juju)> pip
The best and easiest way is this command:
pip install --user package_name
http://www.lleess.com/2013/05/how-to-install-python-modules-without.html#.WQrgubyGOnc
Install virtualenv locally (source of instructions):
Important: Insert the current release (like 16.1.0) for X.X.X.
Check the name of the extracted file and insert it for YYYYY.
$ curl -L -o virtualenv.tar.gz https://github.com/pypa/virtualenv/tarball/X.X.X
$ tar xfz virtualenv.tar.gz
$ python pypa-virtualenv-YYYYY/src/virtualenv.py env
Before you can use or install any package you need to source
your virtual Python environment env
:
$ source env/bin/activate
To install new python packages (like numpy), use:
(env)$ pip install <package>
참고URL : https://stackoverflow.com/questions/7465445/how-to-install-python-modules-without-root-access
'Programing' 카테고리의 다른 글
HTML 버튼을 사용하여 JavaScript 함수 호출 (0) | 2020.04.30 |
---|---|
ASP.NET MVC 응용 프로그램 성능을 개선하려면 어떻게합니까? (0) | 2020.04.30 |
Java 8 스트림의 .min () 및 .max () : 왜 컴파일됩니까? (0) | 2020.04.30 |
dyld : 라이브러리가로드되지 않았습니다… 이유 : 이미지를 찾을 수 없습니다 (0) | 2020.04.30 |
AngularJS에서 HTTP 'Get'서비스 응답을 캐시 하시겠습니까? (0) | 2020.04.30 |