pip安装库包遇到错误:TypeError: expected str, bytes or os.PathLike object, not int 的解决方法

1 问题描述

1、在安装python3的库包时候,遇到和os模块相关的错误:TypeError: expected str, bytes or os.PathLike object, not int,网上给出的解决方法也不多!

在这里插入图片描述

2、我的python3是在系统环境中安装的,并不知anaconda中安装的python3

shl@zhihui-mint:~/shl_res/1_project/python_packages_using/tools/13_2D激光点云投影到图像上$ which python3
/usr/bin/python3
shl@zhihui-mint:~/shl_res/1_project/python_packages_using/tools/13_2D激光点云投影到图像上$ 

2 错误解决方式

2.1 解决方法一:安装的时候,设置PIP_NO_CACHE_DIR为off

1、在安装的时候设置PIP_NO_CACHE_DIR=off,如下:

PIP_NO_CACHE_DIR=off pip3 install opencv-python

pip install package_name --no-cache-dir

2、之后,可以安装了,但是又会遇到错误:ModuleNotFoundError: No module named 'skbuild'

在这里插入图片描述

安装skbuild

pip install scikit-build --no-cache-dir

2.2 解决方法2:

1、安装库包的时候,用指定的python版本进行安装

python3 -m pip install package-name

这样安装的就是python3的库包

2.3 最终解决方法

如果你也是使用pip命令无论是install还是uninstall都会遇到错误:TypeError: expected str, bytes or os.PathLike object, not int,这个主要是由于pip版本导致的!
在这里插入图片描述

解决方法有两种:

  • 临时解决方法
  • 永久解决方法

2.3.1 临时解决方法:不使用缓存

在安装或卸载的时候不使用缓存

PIP_NO_CACHE_DIR=off pip install package_name

=

pip install package_name --no-cache-dir

2.3.2 永久解决方法:更新pip

1、先更新pip

pip install --upgrade pip --no-cache-dir

2、之后就可以正常使用pip了

pip install package_name

参考:https://blog.csdn.net/weixin_41010198/article/details/115669642

  • 25
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
TypeError: expected str, bytes or os.PathLike object, not tuple 这个错误通常发生在使用savemat函数并传入一个元组作为参数时。savemat函数是用于将数据保存到MATLAB格式文件的函数。根据引用中的解决方案,我们可以使用numpy库的asarray函数将元组转换为数组,然后再将数组传递给savemat函数来解决这个问题。 下面是解决savemat TypeError的步骤: 1. 导入numpy库:import numpy as np 2. 将元组转换为数组:data_array = np.asarray(your_tuple) 3. 使用savemat函数保存数据:scipy.io.savemat(file_name, {'data': data_array}) 通过以上步骤,你就可以成功解决savemat TypeError: expected str, bytes or os.PathLike object, not tuple的问题。请确保你已经安装了numpy和scipy库,并将你的元组数据正确传递给savemat函数。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [pip安装pyautogui时报错:TypeError: expected str, bytes or os.PathLike object, not NoneType](https://blog.csdn.net/zhouqiesheng/article/details/131796214)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [解决Python中报错TypeError: must be str, not bytes问题](https://download.csdn.net/download/weixin_38609765/12853546)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值