赞
踩
如果安装了QGIS,在所有程序中搜OSGeo4W Shell,以管理员身份打开,可以安装第三方库
错误尝试:
- 直接安装,不是QGIS中的python
- 切换路径,再次尝试,还是不对
C:\> python3 -m pip install --upgrade pip Requirement already up-to-date: pip in d:\anaconda3\lib\site-packages (20.1.1) C:\>cd /d D:\QGIS 3.12\apps\Python37 D:\QGIS 3.12\apps\Python37> python3 -m pip install --upgrade pip Requirement already up-to-date: pip in d:\anaconda3\lib\site-packages (20.1.1)
- 1
- 2
- 3
- 4
- 5
正确方法(适用于3.18之前版本):
D:\QGIS 3.12\apps\Python37>py3_env.bat
D:\QGIS 3.12\apps\Python37>SET PYTHONHOME=D:\QGIS3~1.12\apps\Python37
D:\QGIS 3.12\apps\Python37>SET PYTHONPATH=D:\QGIS3~1.12\apps\Python37;D:\QGIS3~1.12\apps\Python37\Scripts
D:\QGIS 3.12\apps\Python37>PATH D:\QGIS3~1.12\apps\Python37;D:\QGIS3~1.12\apps\Python37\Scripts;D:\QGIS3~1.12\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBem
注意:使用3.20版本以上需要,设置一下环境变量即可安装python包
C:\OSGeo4W>o4w_env
D:\QGIS 3.12\apps\Python37> python3 -m pip install --upgrade pip
Collecting pip
Downloading pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 819 kB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.0.2
Uninstalling pip-20.0.2:
Successfully uninstalled pip-20.0.2
Successfully installed pip-20.1.1
D:\QGIS 3.12\apps\Python37>pip list Package Version ---------------- ---------- certifi 2019.11.28 chardet 3.0.4 coverage 4.5.1 cycler 0.10.0 decorator 4.4.1 ExifRead 2.1.2 future 0.16.0 GDAL 3.0.4 geographiclib 1.50 httplib2 0.11.3 idna 2.8 ipython-genutils 0.2.0 Jinja2 2.11.1 jsonschema 2.6.0 jupyter-core 4.4.0 kiwisolver 1.1.0 lxml 4.3.3 MarkupSafe 1.1.1 matplotlib 3.1.3 mock 2.0.0 nbformat 4.4.0 networkx 2.2 nose2 0.8.0 numpy 1.18.3 OWSLib 0.17.0 pandas 1.0.1 pbr 4.3.0 Pillow 5.3.0 pip 20.1.1 plotly 3.3.0 ply 3.11 psycopg2-binary 2.8.4 Pygments 2.5.2 pyodbc 4.0.24 PyOpenGL 3.1.0 pyparsing 2.4.6 pypiwin32 223 pyproj 2.5.0 PyQt5 5.11.3 pyqt5-tools 5.13.0.1.5 python-dateutil 2.8.1 python-dotenv 0.10.3 pytz 2019.3 pywin32 224 PyYAML 5.3 requests 2.22.0 retrying 1.3.3 scipy 1.4.1 setuptools 45.2.0 Shapely 1.7.0 simplejson 3.16.0 sip 4.19.14 six 1.14.0 traitlets 4.3.3 urllib3 1.25.8 wxPython 4.0.7 xlrd 1.1.0 xlwt 1.3.0
安装个图像包scikit-image==0.16.1
表示库名+版本号,可以自行更改成其他的
python3 -m pip install scikit-image==0.16.1 --user
示例:
D:\QGIS 3.12\apps\Python37> python3 -m pip install scikit-image==0.16.1 --user Collecting scikit-image==0.16.1 Downloading scikit_image-0.16.1-cp37-cp37m-win_amd64.whl (25.7 MB) |████████████████████████████████| 25.7 MB 392 kB/s Requirement already satisfied: pillow>=4.3.0 in d:\qgis3~1.12\apps\python37\lib\site-packages (from scikit-image==0.16.1) (5.3.0) Collecting imageio>=2.3.0 Downloading imageio-2.8.0-py3-none-any.whl (3.3 MB) |████████████████████████████████| 3.3 MB 3.3 MB/s Requirement already satisfied: networkx>=2.0 in d:\qgis3~1.12\apps\python37\lib\site-packages (from scikit-image==0.16.1) (2.2) Requirement already satisfied: matplotlib!=3.0.0,>=2.0.0 in d:\qgis3~1.12\apps\python37\lib\site-packages (from scikit-image==0.16.1) (3.1.3) Collecting PyWavelets>=0.4.0 Downloading PyWavelets-1.1.1-cp37-cp37m-win_amd64.whl (4.2 MB) |████████████████████████████████| 4.2 MB 3.3 MB/s Requirement already satisfied: scipy>=0.19.0 in d:\qgis3~1.12\apps\python37\lib\site-packages (from scikit-image==0.16.1) (1.4.1) Requirement already satisfied: numpy in d:\qgis3~1.12\apps\python37\lib\site-packages (from imageio>=2.3.0->scikit-image==0.16.1) (1.18.3) Requirement already satisfied: decorator>=4.3.0 in d:\qgis3~1.12\apps\python37\lib\site-packages (from networkx>=2.0->scikit-image==0.16.1) (4.4.1) Requirement already satisfied: kiwisolver>=1.0.1 in d:\qgis3~1.12\apps\python37\lib\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.1) (1.1.0) Requirement already satisfied: cycler>=0.10 in d:\qgis3~1.12\apps\python37\lib\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.1) (0.10.0) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in d:\qgis3~1.12\apps\python37\lib\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.1) (2.4.6) Requirement already satisfied: python-dateutil>=2.1 in d:\qgis3~1.12\apps\python37\lib\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.1) (2.8.1) Requirement already satisfied: setuptools in d:\qgis3~1.12\apps\python37\lib\site-packages (from kiwisolver>=1.0.1->matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.1) (45.2.0) Requirement already satisfied: six in d:\qgis3~1.12\apps\python37\lib\site-packages (from cycler>=0.10->matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.1) (1.14.0) Installing collected packages: imageio, PyWavelets, scikit-image WARNING: The scripts imageio_download_bin.exe and imageio_remove_bin.exe are installed in 'C:\Users\67231\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The script skivi.exe is installed in 'C:\Users\67231\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed PyWavelets-1.1.1 imageio-2.8.0 scikit-image-0.16.1
import skimage
skimage.__version__
'0.16.1'
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。