離線安裝wxpython

離線安裝wxpython

前言

因爲工做環境,個人工做機是在離線環境下的,無法鏈接外網。可是本身又想學習一下wxpython,只好本身手動離線安裝,原本覺得很簡單的,可是實際上。。。一言難盡。python

基本環境:python pip easy_installshell

安裝python2.7

直接下載msi數據包安裝,若是沒法識別安裝,那麼:windows

  • 一、肯定msi數據包的完整性,包括大小、格式;python2.7

  • 二、肯定開啓開啓windows installer:win + R --> 輸入Services.msc --> 找到windows installer --> 左側手動啓用ssh

python3.X 安裝更爲簡單,直接雙擊.exe文件安裝便可,且都須要選定添加環境變量。學習

安裝wxpython

一、下載

下載地址:https://pypi.org/project/wxPython/4.0.1/#files
選擇對應的文件進行安裝,個人選擇是: wxPython-4.0.1-cp27-cp27m-win_amd64.whl測試

其中:ui

cp27 表示 python2.7this

win_amd64 表示 windows 64位code

在這以外:win32 表示 32位

二、安裝

將下載好的wxpython**.whl文件轉移到python安裝路徑下的Scripts目錄下,個人是:C:\Python27\Scripts
而後打開cmd或者powershell,切換到該目錄下:

PS C:\User\Yanta> cd C:\Python27\Scripts

執行命令 pip install wxPython-4.0.1-cp27-cp27m-win_amd64.whl ,此時會報錯:wxPython-4.0.1-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform.

PS C:\Python27\Scripts> pip install .\wxPython-4.0.1-cp27-cp27m-win_amd64.whl
wxPython-4.0.1-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform.

此時能夠嘗試使用easy_install安裝,結果提示缺乏 six 包。

PS C:\Python27\Scripts> .\easy_install-2.7.exe .\wxPython-4.0.1-cp27-cp27m-win_amd64.whl
Processing wxPython-4.0.1-cp27-cp27m-win_amd64.whl
c:\python27\lib\site-packages\setuptools\pep425tags.py:89: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
  warn=(impl == 'cp')):
c:\python27\lib\site-packages\setuptools\pep425tags.py:93: RuntimeWarning: Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
  warn=(impl == 'cp')):
c:\python27\lib\site-packages\setuptools\pep425tags.py:99: RuntimeWarning: Config variable 'Py_UNICODE_SIZE' is unset, Python ABI tag may be incorrect
  sys.version_info < (3, 3))) \
Installing wxPython-4.0.1-cp27-cp27m-win_amd64.whl to c:\python27\lib\site-packages
writing requirements to c:\python27\lib\site-packages\wxPython-4.0.1-py2.7-win-amd64.egg\EGG-INFO\requires.txt
Adding wxPython 4.0.1 to easy-install.pth file
Installing wxdemo-script.py script to c:\python27\Scripts
Installing wxdemo.exe script to c:\python27\Scripts
Installing img2png-script.py script to c:\python27\Scripts
Installing img2png.exe script to c:\python27\Scripts
Installing pyslices-script.py script to c:\python27\Scripts
Installing pyslices.exe script to c:\python27\Scripts
Installing img2py-script.py script to c:\python27\Scripts
Installing img2py.exe script to c:\python27\Scripts
Installing pyslicesshell-script.py script to c:\python27\Scripts
Installing pyslicesshell.exe script to c:\python27\Scripts
Installing wxget-script.py script to c:\python27\Scripts
Installing wxget.exe script to c:\python27\Scripts
Installing helpviewer-script.py script to c:\python27\Scripts
Installing helpviewer.exe script to c:\python27\Scripts
Installing pyshell-script.py script to c:\python27\Scripts
Installing pyshell.exe script to c:\python27\Scripts
Installing pycrust-script.py script to c:\python27\Scripts
Installing pycrust.exe script to c:\python27\Scripts
Installing wxdocs-script.py script to c:\python27\Scripts
Installing wxdocs.exe script to c:\python27\Scripts
Installing pywxrc-script.py script to c:\python27\Scripts
Installing pywxrc.exe script to c:\python27\Scripts
Installing img2xpm-script.py script to c:\python27\Scripts
Installing img2xpm.exe script to c:\python27\Scripts

Installed c:\python27\lib\site-packages\wxpython-4.0.1-py2.7-win-amd64.egg
Processing dependencies for wxPython==4.0.1
Searching for six
Reading https://pypi.python.org/simple/six/
Download error on https://pypi.python.org/simple/six/: [Errno 11004] getaddrinfo failed -- Some packages may not be found!
Couldn't find index page for 'six' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [Errno 11004] getaddrinfo failed -- Some packages may not be found!
No local packages or working download links found for six
error: Could not find suitable distribution for Requirement.parse('six')

而後安裝 six ,下載地址:https://pypi.org/project/six/#files
選擇 six-1.11.0-py2.py3-none-any.whl ,同樣拷貝到C:\Python27\Scripts下,使用pip安裝:

PS C:\Python27\Scripts> .\easy_install-2.7.exe .\six-1.11.0-py2.py3-none-any.whl
Processing six-1.11.0-py2.py3-none-any.whl
c:\python27\lib\site-packages\setuptools\pep425tags.py:89: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
  warn=(impl == 'cp')):
c:\python27\lib\site-packages\setuptools\pep425tags.py:93: RuntimeWarning: Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
  warn=(impl == 'cp')):
c:\python27\lib\site-packages\setuptools\pep425tags.py:99: RuntimeWarning: Config variable 'Py_UNICODE_SIZE' is unset, Python ABI tag may be incorrect
  sys.version_info < (3, 3))) \
Installing six-1.11.0-py2.py3-none-any.whl to c:\python27\lib\site-packages
Adding six 1.11.0 to easy-install.pth file

Installed c:\python27\lib\site-packages\six-1.11.0-py2.7.egg
Processing dependencies for six==1.11.0
Finished processing dependencies for six==1.11.0

此時再次使用easy_install安裝wxpython便可:

PS C:\Python27\Scripts> .\easy_install-2.7.exe .\wxPython-4.0.1-cp27-cp27m-win_amd64.whl
Processing wxPython-4.0.1-cp27-cp27m-win_amd64.whl
c:\python27\lib\site-packages\setuptools\pep425tags.py:89: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
  warn=(impl == 'cp')):
c:\python27\lib\site-packages\setuptools\pep425tags.py:93: RuntimeWarning: Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
  warn=(impl == 'cp')):
c:\python27\lib\site-packages\setuptools\pep425tags.py:99: RuntimeWarning: Config variable 'Py_UNICODE_SIZE' is unset, Python ABI tag may be incorrect
  sys.version_info < (3, 3))) \
removing 'c:\python27\lib\site-packages\wxPython-4.0.1-py2.7-win-amd64.egg' (and everything under it)
Installing wxPython-4.0.1-cp27-cp27m-win_amd64.whl to c:\python27\lib\site-packages
writing requirements to c:\python27\lib\site-packages\wxPython-4.0.1-py2.7-win-amd64.egg\EGG-INFO\requires.txt
wxPython 4.0.1 is already the active version in easy-install.pth
Installing wxdemo-script.py script to c:\python27\Scripts
Installing wxdemo.exe script to c:\python27\Scripts
Installing img2png-script.py script to c:\python27\Scripts
Installing img2png.exe script to c:\python27\Scripts
Installing pyslices-script.py script to c:\python27\Scripts
Installing pyslices.exe script to c:\python27\Scripts
Installing img2py-script.py script to c:\python27\Scripts
Installing img2py.exe script to c:\python27\Scripts
Installing pyslicesshell-script.py script to c:\python27\Scripts
Installing pyslicesshell.exe script to c:\python27\Scripts
Installing wxget-script.py script to c:\python27\Scripts
Installing wxget.exe script to c:\python27\Scripts
Installing helpviewer-script.py script to c:\python27\Scripts
Installing helpviewer.exe script to c:\python27\Scripts
Installing pyshell-script.py script to c:\python27\Scripts
Installing pyshell.exe script to c:\python27\Scripts
Installing pycrust-script.py script to c:\python27\Scripts
Installing pycrust.exe script to c:\python27\Scripts
Installing wxdocs-script.py script to c:\python27\Scripts
Installing wxdocs.exe script to c:\python27\Scripts
Installing pywxrc-script.py script to c:\python27\Scripts
Installing pywxrc.exe script to c:\python27\Scripts
Installing img2xpm-script.py script to c:\python27\Scripts
Installing img2xpm.exe script to c:\python27\Scripts

Installed c:\python27\lib\site-packages\wxpython-4.0.1-py2.7-win-amd64.egg
Processing dependencies for wxPython==4.0.1
Finished processing dependencies for wxPython==4.0.1

三、測試

安裝事後測試一下,是否能夠導入wx包:

PS C:\Python27\Scripts> py -2          
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx

四、NOTE

本機安裝有python2.7和3.6兩個版本,使用py -2 和py -3分別指向2.7和3.6,在python腳本中使用:

#!/user/bin/env python2

#!/user/bin/env python3

分別指定便可。

相關文章
相關標籤/搜索