Python Windows 패키지를 virtualenvs에 설치할 수 있습니까?
Virtualenv는 훌륭합니다. 다른 프로젝트의 종속성이 모두 공통된 더미에 함께 포함되지 않도록 여러 개의 개별 Python 설치를 유지할 수 있습니다.
그러나 .exe 설치 프로그램으로 패키지 된 Windows에 패키지를 설치하려면 virtualenv에 설치하도록 지시하려면 어떻게해야합니까? 예를 들어 pycuda-0.94rc.win32-py2.6.exe가 있습니다. 내가 그것을 실행할 때, 그것은 레지스트리를 검사하고 설치할 virtual26의 하나 인 Python26만을 찾습니다.
virtualenv에 설치하도록 지시하려면 어떻게해야합니까?
그래 넌 할수있어. 당신이 필요한 전부
easy_install binary_installer_built_with_distutils.exe
놀랐나요? distutils로 만든 Windows 용 이진 설치 관리자는 .exe와 .zip을 하나의 .exe 파일로 결합합니다. 확장자가 .zip으로 변경되어 유효한 zip 파일인지 확인하십시오. 내 질문에 대한 답변을 읽은 후 이것을 발견 했습니다. Windows 용 psycopg2로 이진 계란을 어디서 다운로드 할 수 있습니까?
최신 정보
요즘 Tritium21이 그의 대답에서 언급했듯이 easy_install 대신 pip를 사용해야합니다. Pip은 distutils로 만든 이진 패키지를 설치할 수 없지만 새로운 휠 형식으로 이진 패키지를 설치할 수 있습니다 . 휠 패키지를 사용하여 이전 형식에서 새 형식으로 변환 할 수 있습니다 . 먼저 휠 패키지를 설치해야합니다.
나는 이것이 매우 오래된 질문이라는 것을 알고 있으며 내가 이야기하려고하는 도구보다 먼저 사용하지만 Google을 위해 언급하는 것이 좋습니다. easy_install은 파이썬 패키징의 검은 양입니다. 아무도 새로운 핍의 핍으로 그것을 사용하고 싶어하지 않습니다. 또한 레지스트리 트릭을 재생하는 것은 비표준 EXE 설치 프로그램에서 가장 잘 작동하지만 (누군가 distutils를 사용하지 않고 설치 프로그램을 직접 작성하고 설치 경로를 레지스트리를 확인하고 있음) 표준 EXE 설치 프로그램에 대한 더 나은 방법 (c)이 있습니다. .
pip install wheel
wheel convert INSTALLER.EXE
pip install NEW_FILE_CREATED_IN_LAST_STEP.whl
이 포스트에서 최근에 소개 된 휠 형식은 달걀 형식을 대체하는 것과 거의 같은 역할을합니다. 이 형식은 pip (virtualv에 이미 설치된 도구)에서도 지원됩니다.
어떤 이유로 든 pip install WHEELFILE
작동하지 않으면 시도하십시오wheel install WHEELFILE
레지스트리에 Python 설치를 등록하기 위해 스크립트 ( http://effbot.org/zone/python-register.htm )를 수정했습니다 . 내가 할 파이썬을 선택할 수 있습니다 , 레지스트리에서 파이썬 윈도우 설치 프로그램을 실행 한 후 레지스트리 다시 설정 :
# -*- encoding: utf-8 -*-
#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# Adapted by Ned Batchelder from a script
# written by Joakim Löw for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
import sys
from _winreg import *
# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
installpath, installpath, installpath
)
def RegisterPy():
try:
reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)
except EnvironmentError:
try:
reg = CreateKey(HKEY_LOCAL_MACHINE, regpath)
except Exception, e:
print "*** Unable to register: %s" % e
return
SetValue(reg, installkey, REG_SZ, installpath)
SetValue(reg, pythonkey, REG_SZ, pythonpath)
CloseKey(reg)
print "--- Python %s at %s is now registered!" % (version, installpath)
if __name__ == "__main__":
RegisterPy()
등록하고자하는 Python으로이 스크립트를 실행하면 레지스트리에 입력됩니다. Windows 7 및 Vista에서는 관리자 권한이 필요합니다.
easy_install은 널리 사용되는 많은 패키지를 다루는 distutils의 bdist_wininst 대상을 사용하여 빌드 된 .exe 패키지를 설치할 수 있습니다. 그러나 그렇지 않은 많은 것들이 있습니다 (wxPython은 내가 고투 한 것입니다)
환경의 easy_install을 사용하여 PyCUDA를 설치할 수 있습니다.
dev-env-path/bin/easy_install pycuda
동일한 버전 0.94rc를 제공합니다.
On Windows easy_install.exe will be in Scripts directory.
If it's a .msi
, you might be able to specify command line options using msiexec
. The Python installer itself allows TARGETDIR
, but I'm not sure if distutils bakes this into distribution installers.
If you're using a .exe
, I don't think there's a clean way. One option is to use a program like 7Zip (or winzip, etc) to directly extract the contents of the exe, then copy the relevent folders into your virtual site-packages folder. For example, if I extract "processing-0.5.2.win32-py2.5.exe", I find a folder "PLATLIB\processing" which I copy to a virtualenv path and use without any runtime problems. (I'm not sure it's always that simple though.)
참고URL : https://stackoverflow.com/questions/3271590/can-i-install-python-windows-packages-into-virtualenvs
'programing tip' 카테고리의 다른 글
언제 노조를 사용하겠습니까? (0) | 2020.07.08 |
---|---|
Java FileReader 인코딩 문제 (0) | 2020.07.08 |
Android Studio에서 debug.keystore는 어디에 있습니까? (0) | 2020.07.08 |
각도 2.0 및 모달 대화 상자 (0) | 2020.07.08 |
자바 : 문자열에서 일치하는 위치를 얻는 방법? (0) | 2020.07.08 |