programing

.whl 파일이있는 Python 패키지를 어떻게 설치합니까?

nasanasas 2020. 9. 29. 07:55
반응형

.whl 파일이있는 Python 패키지를 어떻게 설치합니까?


Windows 컴퓨터에 Python 패키지 (특히 JPype1 0.5.7)를 설치하는 데 문제가 있으며 Christoph Gohlke의 Window 바이너리와 함께 설치하고 싶습니다. (내 경험에 비추어 볼 때, 다른 많은 패키지 설치에 대한 소란을 많이 완화했습니다.)

그러나 Christoph는 과거에 .exe 파일을 제공했지만 최근에는 대신 .whl 파일을 업로드하는 것으로 보입니다.

http://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype

하지만 .whl 파일을 어떻게 설치합니까?

메모:

  • wheel 에서 문서를 찾았 지만 .whl 파일을 설치하는 방법을 설명하는 데 그다지 정직하지 않은 것 같습니다.
  • 이 질문은 직접 답변되지 않은 이 질문 과 중복 된 질문입니다 .

나는 아주 간단한 다음을 사용했습니다. 먼저 콘솔을 열고 some-package.whl과 같은 파일을 다운로드 한 위치로 cd하고

pip install some-package.whl

참고 : pip.exe가 인식되지 않으면 python이 설치된 "Scripts"디렉토리에서 찾을 수 있습니다. pip가 설치되지 않은 경우이 페이지가 도움이 될 수 있습니다. Windows에 pip를 어떻게 설치합니까?

참고 : 설명을
위해 *.whl파일을 로컬 드라이브 (예 : C : \ some-dir \ some-file.whl )에 복사 하는 경우 다음 명령 줄 매개 변수를 사용하십시오.

pip install C:/some-dir/some-file.whl

휠에서 설치하려면 휠이 다운로드 된 디렉토리를 지정하십시오. 예를 들어 다음을 설치합니다 package_name.whl.

pip install --use-wheel --no-index --find-links=/where/its/downloaded package_name

휠 지원을 활성화하려면 먼저 pip를 업데이트했는지 확인하십시오.

pip install --upgrade pip

나는 OP와 같은 배에 있습니다.

Windows 명령 프롬프트를 사용하여 디렉토리에서 :

C:\Python34\Scripts>
pip install wheel

작동하는 것 같았습니다.

whl이 위치한 곳으로 디렉토리를 변경하면 'pip가 인식되지 않습니다'라는 메시지가 표시됩니다. 로 돌아가서 C:\Python34\Scripts>위의 전체 명령을 사용하여 'where / its / downloaded'위치를 제공하면 Requirement 'scikit_image-...-win32.whl' looks like a filename, but the filename does not exist.

그래서 Python34 / Scripts에서 .whl의 복사본을 삭제하고 똑같은 명령을 다시 실행했습니다 ( --find-links=여전히 다른 폴더로 이동). 이번에는 작동했습니다.


위대한 Christoph Gohlke 사이트에는 여러 파일 버전이 있습니다.

이 사이트에서 휠을 설치할 때 중요한 것은 Python 콘솔에서 먼저 실행하는 것입니다.

import pip
print(pip.pep425tags.get_supported())

컴퓨터에 어떤 버전을 설치해야하는지 알 수 있습니다. 잘못된 버전을 선택하면 패키지 설치가 실패 할 수 있습니다 (특히 올바른 CPython 태그 (예 : cp27)를 사용하지 않는 경우).


내 컴퓨터의 명령 프롬프트에서 pip.exe를 실행해야합니다. 나는 타이핑한다C:/Python27/Scripts/pip2.exe install numpy


Windows에서는을 사용하여 업그레이드 할 수 없습니다 pip install --upgrade pip. pip.exe이 사용 중이고이를 대체하는 데 오류가있을 수 있기 때문입니다. 대신 다음 pip과 같이 업그레이드해야 합니다.

easy_install --upgrade pip

그런 다음 pip버전을 확인하십시오 .

pip --version

6.x시리즈가 표시되면 휠 지원이 있습니다.

그래야만 다음과 같은 휠 패키지를 설치할 수 있습니다.

pip install your-package.whl

두 번 클릭하여 휠 파일을 설치하려면 다음 중 하나를 수행하십시오.

1) 관리자 권한으로 명령 줄에서 두 개의 명령을 실행합니다.

assoc .whl=pythonwheel
ftype pythonwheel=cmd /c pip.exe install "%1" ^& pause

2) 또는 wheel.bat속성에서 '관리자 권한으로 실행'확인란을 선택 하여 파일에 복사하여 실행할 수 있습니다 .

PS pip.exe는 PATH에있는 것으로 간주됩니다.

최신 정보:

(1) 이들은 한 줄로 결합 할 수 있습니다.

assoc .whl=pythonwheel& ftype pythonwheel=cmd /c pip.exe install -U "%1" ^& pause

(2) Syntax for .bat files is slightly different:

assoc .whl=pythonwheel& ftype pythonwheel=cmd /c pip.exe install -U "%%1" ^& pause

Also its output can be made more verbose:

@assoc .whl=pythonwheel|| echo Run me with administrator rights! && pause && exit 1
@ftype pythonwheel=cmd /c pip.exe install -U "%%1" ^& pause || echo Installation error && pause && exit 1
@echo Installation successfull & pause

see my blog post for details.


In-case if you unable to install specific package directly using PIP.

You can download a specific .whl (wheel) package from - https://www.lfd.uci.edu/~gohlke/pythonlibs/

CD (Change directory) to that downloaded package and install it manually by -
pip install PACKAGENAME.whl
ex:
pip install ad3‑2.1‑cp27‑cp27m‑win32.whl


EDIT: THIS NO LONGER IS A PART OF PIP

To avoid having to download such files, you can try:

pip install --use-wheel pillow

For more information, see this.


The only way I managed to install NumPy was as follows:

I downloaded NumPy from here https://pypi.python.org/pypi/numpy

This Module

https://pypi.python.org/packages/d7/3c/d8b473b517062cc700575889d79e7444c9b54c6072a22189d1831d2fbbce/numpy-1.11.2-cp35-none-win32.whl#md5=e485e06907826af5e1fc88608d0629a2

Command execution from Python's installation path in PowerShell

PS C:\Program Files (x86)\Python35-32> .\python -m pip install C:/Users/MyUsername/Documents/Programs/Python/numpy-1.11.2-cp35-none-win32.whl
Processing c:\users\MyUsername\documents\programs\numpy-1.11.2-cp35-none-win32.whl
Installing collected packages: numpy
Successfully installed numpy-1.11.2
PS C:\Program Files (x86)\Python35-32>

PS.: I installed it on Windows 10.


You can install the .whl file, using pip install filename. Though to use it in this form, it should be in the same directory as your command line, otherwise specify the complete filename, along with its address like pip install C:\Some\PAth\filename.

Also make sure the .whl file is of the same platform as you are using, do a python -V to find out which version of Python you are running and if it is win32 or 64, install the correct version according to it.


What I did was first updating the pip by using the command: pip install --upgrade pip and then I also installed wheel by using command: pip install wheel and then it worked perfectly Fine.

Hope it works for you I guess.


New Python users on Windows often forget to add Python's \Scripts directory to the PATH variable during the installation. I recommend to use the Python launcher and execute pip as a script with the -m switch. Then you can install the wheels for a specific Python version (if more than one are installed) and the Scripts directory doesn't have to be in the PATH. So open the command line, navigate (with the cd command) to the folder where the .whl file is located and enter:

py -3.6 -m pip install your_whl_file.whl

Replace 3.6 by your Python version or just enter -3 if the desired Python version appears first in the PATH. And with an active virtual environment: py -m pip install your_whl_file.whl.

Of course you can also install packages from PyPI in this way, e.g.

py -3.6 -m pip install pygame

I would be suggesting you the exact way how to install .whl file. Initially I faced many issues but then I solved it, Here is my trick to install .whl files.

Follow The Steps properly in order to get a module imported

  1. Make sure your .whl file is kept in the python 2.7/3.6/3.7/.. folder. Initially when you download the .whl file the file is kept in downloaded folder, my suggestion is to change the folder. It makes it easier to install the file.
  2. Open command prompt and open the folder where you have kept the file by entering

cd c:\python 3.7

3.Now, enter the command written below

>py -3.7(version name) -m pip install (file name).whl
  1. Click enter and make sure you enter the version you are currently using with correct file name.

  2. Once you press enter, wait for few minutes and the file will be installed and you will be able to import the particular module.

  3. In order to check if the module is installed successfully, import the module in idle and check it.

Thank you:)


On the MacOS, with pip installed via MacPorts into the MacPorts python2.7, I had to use @Dunes solution:

sudo python -m pip install some-package.whl

Where python was replaced by the MacPorts python in my case, which is python2.7 or python3.5 for me.

The -m option is "Run library module as script" according to the manpage.

(I had previously run sudo port install py27-pip py27-wheel to install pip and wheel into my python 2.7 installation first.)

참고URL : https://stackoverflow.com/questions/27885397/how-do-i-install-a-python-package-with-a-whl-file

반응형