在 Linux Ubuntu 18.04 上从 pip 安装 cartopy 退出并出现各种错误

shell 命令pip install cartopy导致了几个错误。


起初,出现以下错误:


    ERROR: Command errored out with exit status 1:

     command: /home/linuxbrew/.linuxbrew/opt/python@3.8/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-j47_isf2/cartopy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-j47_isf2/cartopy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-a9f6gipd

         cwd: /tmp/pip-install-j47_isf2/cartopy/

    Complete output (3 lines):

    /tmp/pip-install-j47_isf2/cartopy/setup.py:157: UserWarning: Unable to determine Proj version. Ensure you have 4.9.0 or later installed, or installation may fail.

      warnings.warn(

    Proj version 0.0.0 is installed, but cartopy requires at least version 4.9.0.

    ----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

重新安装 proj4 并尝试在我的.bashrc文件中传递环境变量后,例如


export PROJ_LIB=/home/linuxbrew/.linuxbrew/bin/proj

export PROJ=/home/linuxbrew/.linuxbrew/bin/proj


猛跑小猪
浏览 233回答 1
1回答

HUX布斯

在搜索主要错误消息的解决方案之后c++: error: unrecognized command line option '-R'我所做的是使用强大的方法搜索相关文件find:andylu@andylu-ThinkPad-Edge-E130:~/Desktop/Python/Scripts$ sudo find / -type f -iname "unixccompiler.py"find: ‘/run/user/1000/gvfs’: Permission deniedfind: ‘/tmp/.mount_pcloudgeFVGR’: Permission denied/snap/core/9436/usr/lib/python3.5/distutils/unixccompiler.py/snap/core/9665/usr/lib/python3.5/distutils/unixccompiler.py/snap/gimp/281/usr/lib/python2.7/distutils/unixccompiler.py/snap/gimp/273/usr/lib/python2.7/distutils/unixccompiler.py/snap/core18/1880/usr/lib/python3.6/distutils/unixccompiler.py/snap/core18/1880/usr/lib/python3.7/distutils/unixccompiler.py/snap/core18/1880/usr/lib/python3.8/distutils/unixccompiler.py/snap/core18/1754/usr/lib/python3.6/distutils/unixccompiler.py/snap/core18/1754/usr/lib/python3.7/distutils/unixccompiler.py/snap/core18/1754/usr/lib/python3.8/distutils/unixccompiler.py/usr/lib/python3.8/distutils/unixccompiler.py/usr/lib/python3.6/distutils/unixccompiler.py/usr/lib/python3/dist-packages/numpy/distutils/unixccompiler.py/usr/lib/python3.7/distutils/unixccompiler.py/usr/lib/python2.7/distutils/unixccompiler.py/usr/lib/python2.7/dist-packages/numpy/distutils/unixccompiler.pyfind: ‘/home/andylu/pCloudDrive’: Permission denied/home/linuxbrew/.linuxbrew/Cellar/python@3.8/3.8.5/libexec/setuptools/build/lib/setuptools/_distutils/unixccompiler.py/home/linuxbrew/.linuxbrew/Cellar/python@3.8/3.8.5/libexec/setuptools/setuptools/_distutils/unixccompiler.py/home/linuxbrew/.linuxbrew/Cellar/python@3.8/3.8.5/lib/python3.8/distutils/unixccompiler.py/home/linuxbrew/.linuxbrew/Cellar/numpy/1.19.1/lib/python3.8/site-packages/numpy/distutils/unixccompiler.py/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/numpy/distutils/unixccompiler.py/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/setuptools/_distutils/unixccompiler.pyversion 3.8接下来,我打开了包含当前在我的文本编辑器中使用的相关 python 文件VS Code。然后,我在这些文件中搜索“-R”以找到以下代码片段:        else:            if self._is_gcc(compiler):                # gcc on non-GNU systems does not need -Wl, but can                # use it anyway.  Since distutils has always passed in                # -Wl whenever gcc was used in the past it is probably                # safest to keep doing so.                if sysconfig.get_config_var("GNULD") == "yes":                    # GNU ld needs an extra option to get a RUNPATH                    # instead of just an RPATH.                    return "-Wl,--enable-new-dtags,-R" + dir                else:                    return "-Wl,-R" + dir            else:                # No idea how --enable-new-dtags would be passed on to                # ld if this system was using GNU ld.  Don't know if a                # system like this even exists.                return "-R" + dir在这个代码片段中,我用"-R"和"-rpath="最后一个独立的"-R"(上面代码片段的最后一行)甚至用'-Wl,-rpath='. 完成后,代码片段如下所示:    else:        if self._is_gcc(compiler):            # gcc on non-GNU systems does not need -Wl, but can            # use it anyway.  Since distutils has always passed in            # -Wl whenever gcc was used in the past it is probably            # safest to keep doing so.            if sysconfig.get_config_var("GNULD") == "yes":                # GNU ld needs an extra option to get a RUNPATH                # instead of just an RPATH.                return "-Wl,--enable-new-dtags,-rpath=" + dir            else:                return "-Wl,-rpath=" + dir        else:            # No idea how --enable-new-dtags would be passed on to            # ld if this system was using GNU ld.  Don't know if a            # system like this even exists.            return "-Wl,-rpath=" + dir保存并关闭上述修改后的python-scripts后,cartopy的安装终于成功了:andylu@andylu-ThinkPad-Edge-E130:~/Desktop/Python/Scripts$ pip install cartopyCollecting cartopy  Using cached Cartopy-0.18.0.tar.gz (14.4 MB)Requirement already satisfied: numpy>=1.10 in /home/linuxbrew/.linuxbrew/lib/python3.8/site-packages (from cartopy) (1.19.1)Requirement already satisfied: shapely>=1.5.6 in /home/linuxbrew/.linuxbrew/lib/python3.8/site-packages (from cartopy) (1.7.0)Requirement already satisfied: pyshp>=1.1.4 in /home/linuxbrew/.linuxbrew/lib/python3.8/site-packages (from cartopy) (2.1.0)Requirement already satisfied: six>=1.3.0 in /home/linuxbrew/.linuxbrew/lib/python3.8/site-packages (from cartopy) (1.15.0)Requirement already satisfied: setuptools>=0.7.2 in /home/linuxbrew/.linuxbrew/lib/python3.8/site-packages (from cartopy) (49.2.1)Building wheels for collected packages: cartopy  Building wheel for cartopy (setup.py) ... done  Created wheel for cartopy: filename=Cartopy-0.18.0-cp38-cp38-linux_x86_64.whl size=15743039 sha256=b95932012d877432db8e629bdc77e730227f93f94515a54e59e4c6fb6a85bdad  Stored in directory: /home/andylu/.cache/pip/wheels/7c/3c/68/ed800c08e3e6579b632fdd26becee97c5c5474625f6c97eca6Successfully built cartopyInstalling collected packages: cartopySuccessfully installed cartopy-0.18.0
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python