ubuntu python3.8安装第三方库astroscrappy出现的问题及解决方法记录

本文记录了在使用Python安装Astroscrappy过程中遇到的错误,并提供了详细的解决方案,包括安装必要的依赖包。

Defaulting to user installation because normal site-packages is not writeable
Collecting astroscrappy
  Using cached astroscrappy-1.0.8.tar.gz (449 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.8 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hrypw0uc/astroscrappy_698d83c789de4fc7b154bdfcb64960cf/setup.py'"'"'; __file__='"'"'/tmp/pip-install-hrypw0uc/astroscrappy_698d83c789de4fc7b154bdfcb64960cf/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-viduca_0
         cwd: /tmp/pip-install-hrypw0uc/astroscrappy_698d83c789de4fc7b154bdfcb64960cf/
    Complete output (59 lines):
      ERROR: Command errored out with exit status 1:
       command: /usr/bin/python3.8 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-9kn9l6h7/astropy-helpers_442ddd241fae4a98990334bb16bffc92/setup.py'"'"'; __file__='"'"'/tmp/pip-wheel-9kn9l6h7/astropy-helpers_442ddd241fae4a98990334bb16bffc92/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-9idh6644
           cwd: /tmp/pip-wheel-9kn9l6h7/astropy-helpers_442ddd241fae4a98990334bb16bffc92/
      Complete output (6 lines):
      usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help
    
      error: invalid command 'bdist_wheel'
      ----------------------------------------
      ERROR: Failed building wheel for astropy-helpers
    ERROR: Failed to build one or more wheels

 

 

解决方法:

sudo apt-get install python3.6-dev
sudo apt-get install wheel

 

### Ubuntu Python 3.8 安装 GDAL 库的方法 #### 方法一:通过 APT 包管理器安装 对于基于 Ubuntu 的系统,可以利用系统的包管理工具 `apt` 来简化 GDAL 及其 Python 绑定的安装过程。这通常是最简单的方式之一。 确保更新软件源列表并添加 Ubuntugis PPA 仓库来获得最新版本的支持: ```bash sudo add-apt-repository ppa:ubuntugis/ppa sudo apt update ``` 接着安装必要的依赖项以及 GDAL 工具和开发文件: ```bash sudo apt install libpq-dev sudo apt install gdal-bin sudo apt install libgdal-dev ``` 为了使 Python 能够识别到新安装的 GDAL 版本,在安装对应的 Python 绑定之前,建议先确认当前使用的 GDAL 版本号以便匹配安装相同版本的绑定库: ```bash gdalinfo --version ``` 最后使用 pip 安装与上述命令返回的具体版本相一致的 GDAL Python 接口: ```bash pip install "gdal==$(gdal-config --version)" ``` 这种方法适用于大多数情况下的常规需求[^1]。 #### 方法二:通过 Conda 创建独立环境安装 另一种推荐方式是在 Anaconda 或 Miniconda 中创建专门针对 Python 3.8 的虚拟环境,并从中安装所需组件。这种方式能够更好地隔离不同项目之间的依赖关系冲突问题。 首先创建一个新的 Python 3.8 环境: ```bash conda create -n py38 python=3.8 ``` 激活该环境后再执行 GDAL 的安装操作: ```bash conda activate py38 conda install -c conda-forge gdal ``` 此方法不仅解决了可能存在的路径配置难题,还提供了更灵活便捷的方式来管理和切换不同的工作空间及其各自的依赖设置[^2]。 #### 方法三:手动编译安装 如果需要特定版本或其他定制化选项,则可以选择从源码编译安装。不过在此之前需确保已准备好 GCC 编译器及其他必要构建工具: ```bash sudo apt-get install build-essential ``` 之后按照官方文档指导完成下载、解压、配置、编译等一系列步骤。考虑到复杂度较高且容易遇到各种兼容性挑战,除非有特殊理由一般不推荐采用此种方案[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值