第一次安装失败! 安装python3.8.3 无法使用pip,ssl问题: 问题:WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.Could not fetch URL https:///simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(ho 解决:参考博客https://www.cnblogs.com/jessepeng/p/12307875.html 首先查看OpenSSL版本,版本太低,确实是因为该原因 查看openssl版本命令 openssl version 根据https://www.cnblogs.com/ExMan/p/10301129.html所述python3.7之后为了安全性考虑,要求使用openssl 1.0.2之后的版本 于是 根据https://www.cnblogs.com/jessepeng/p/12307875.html (Linux非root安装Python3以及解决SSL问题)继续安装操作 首先删除上次安装好的python wget -c https://www./source/openssl-1.1.1d.tar.gz (有时候wget超时,版本可以根据官网自行下载) tar -xvf openssl-1.1.1d.tar.gz cd openssl-1.1.1d ./config --prefix=/public/home/fkyang/tools/install/openssl no-zlib #注意添加no-zlib make && make install 安装完后,直接可以配置环境变量和python安装文件中修改(博客中出现其他问题我们不去深究): vi ~/.bashrc export LD_LIBRARY_PATH=/public/home/fkyang/tools/install/openssl/lib:$LD_LIBRARY_PATH (Esc :wq Enter) 退出并保存.bashrc source ~/.bashrc 且修改python安装包中的Modules/Setup文件 vi Setup 四行取消注释,并将SSL路径修改 SSL=/public/home/fkyang/tools/install/openssl #改为刚安装的ssl路径 _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto (Esc :wq Enter) 退出并保存Setup 最后安装python3.8.3(自己需求) ./configure --prefix=/public/home/fkyang/tools/python3/ make && make install # 配置环境 #配置python export PYTHON_HOME=/public/home/fkyang/tools/python3 export PATH=$PYTHON_HOME/bin:$PATH 直接运行python3.8和pip3.8 ($path/bin中查看如何使用python和pip) 如果pip版本较低会出现这种警告: WARNING: You are using pip version 19.2.3, however version 21.1.2 is available. You should consider upgrading via the 'pip install --upgrade pip' command. 可以update:pip3.8 install --upgrade pip 安装必需的包库: 网络数据的抓取(requests、urllib、bs4)、数据分析及可视化(numpy、matplotlib、pyecharts、pandas)、计算机视觉及图像处理(cv2、PIL 包括gdal shapely fiona basemap (pyproj) rasterio geopandas(shapely和fiona) scikit-learn tensorflow pip3.8 install numpy 检验:$:python3.8 >>import numpy >> pip3.8 install pandas 检验:$:python3.8 >>import pandas >> pip3.8 install matplotlib 检验:$:python3.8 >>import matplotlib >> 问题: >>> import matplotlib.pyplot as plt Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 78, in <module> new_figure_manager, draw_if_interactive, show = pylab_setup() File "/usr/lib64/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup globals(),locals(),[backend_name]) File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module> from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\ File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 8, in <module> import gtk; gdk = gtk.gdk File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module> _init() File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init _gtk.init_check() RuntimeError: could not open display 这是display错误,之前的解决办法是在网上查资料得到的,使用的是Xmanger这个小软件,成功了连接了本地和虚拟机,可以在虚拟机终端的形式下输出图片,也可以保存、展示。但是如果Xmanger无法使用, 解决方法 >>> import matplotlib as mpl >>> mpl.use('Agg') >>> import matplotlib.pyplot as plt 继续安装: pip3.8 install pyproj pip3.8 install fiona pip3.8 install shapely pip3.8 install scikit-learn 问题: >>import sklearn Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/public/home/fkyang/tools/python3/lib/python3.8/site-packages/sklearn/__init__.py", line 82, in <module> from .base import clone File "/public/home/fkyang/tools/python3/lib/python3.8/site-packages/sklearn/base.py", line 17, in <module> from .utils import _IS_32BIT File "/public/home/fkyang/tools/python3/lib/python3.8/site-packages/sklearn/utils/__init__.py", line 20, in <module> from scipy.sparse import issparse File "/public/home/fkyang/tools/python3/lib/python3.8/site-packages/scipy/__init__.py", line 144, in <module> from scipy._lib._ccallback import LowLevelCallable File "/public/home/fkyang/tools/python3/lib/python3.8/site-packages/scipy/_lib/_ccallback.py", line 1, in <module> from . import _ccallback_c File "_ccallback_c.pyx", line 210, in init scipy._lib._ccallback_c File "/public/home/fkyang/tools/python3/lib/python3.8/ctypes/__init__.py", line 7, in <module> from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes' 解决: python3.7以上版本需要一个新的依赖包libffi-devel,centos系统环境中缺乏这个包# yum install libffi-devel -y 但是在非root下无法安装,使用不了yum和rpm
第二次安装成功! 安装python3.6.6 由于python3.7以上版本使用不了skleran,更改python3.6 wget https://www./ftp/python/3.6.6/Python-3.6.6.tgz tar -xvf Python-3.6.6.tgz ./configure --prefix=/public/home/fkyang/tools/python3/ make && make install 继续pip所需要的包库: pip3.6 install numpy 检验:$:python3.6 >>>import numpy >> pip3.6 install pandas 检验:$:python3.6 >>>import pandas >> pip3.6 install matplotlib 检验:$:python3.6 >>>import matplotlib >>> import matplotlib.pyplot as plt 安装python3.6后matplotlib 可以正常使用 pip3.6 install scikit-learn 检验:$:python3.6 >>>from sklearn.ensemble import RandomForestRegressor pip3.6 install pyproj 未成功 问题: Installing build dependencies ... done Complete output from command python setup.py egg_info: proj executable not found. Please set the PROJ_DIR variable. For more information see: https://pyproj4./pyproj/stable/installation.html Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-vys0tpd3/pyproj/ 解决: 将pip更新之后再安装就可以了 pip install --upgrade pip pip3.6 install pyproj 成功 pip3.6 install fiona 检验:$:python3.6 >>>import fiona pip3.6 install shapely 检验:$:python3.6 >>>from shapely.geometry import Point shape数据 pip3.6 install geopandas 检验:$:python3.6 >>>import geopandas as gp shape数据 pip3.6 install netCDF4 检验:$:python3.6 >>>from netCDF4 import Dataset nc数据 pip3.6 install pygrib 检验:$:python3.6 >>>import pygrib grib数据 pip3.6 install rasterio 检验:$:python3.6 >>> from rasterio.plot import show tiff数据 pip3.6 install joblib pip3.6 install scipy pip3.6 install tensorflow pip3.6 install keras
|