pip 安装库时出现TypeError: expected str, bytes or os.PathLike object, not int

pip 安装库时出现TypeError: expected str, bytes or os.PathLike object, not int

查看pip版本号

在Ubuntu端的anaconda创建新的虚拟环境,也不清楚哪边问题,在新创环境之后,查看已安装的库或者安装新的库时,就会出现以下报错

Exception:
Traceback (most recent call last):
  File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/commands/install.py", line 272, in run
    with self._build_session(options) as session:
  File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/basecommand.py", line 69, in _build_session
    if options.cache_dir else None
  File "/home/。。。/anaconda3/envs/torch/lib/python3.6/posixpath.py", line 78, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not int
Traceback (most recent call last):
  File "/home/。。。/anaconda3/envs/torch/bin/pip", line 6, in <module>
    sys.exit(pip.main())
  File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/__init__.py", line 249, in main
    return command.main(cmd_args)
  File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/basecommand.py", line 251, in main
    timeout=min(5, options.timeout)) as session:
  File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/basecommand.py", line 69, in _build_session
    if options.cache_dir else None
  File "/home/。。。/anaconda3/envs/torch/lib/python3.6/posixpath.py", line 78, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not int

然后看到网上资料,大部分都是说pip9.0的版本导致的会出这种问题,pip list查询我的环境,确实也是pip9.0的这个版本。

但是大部分的方法,我都尝试过了,让去更新pip,pip install --upgrade pip,但是这个命令,还是出现上面那个报错,pip还是没更新成功。

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

我们 更新pip 不使用缓存,更新pip即可跳过报错,实现更新,解决问题!

在这里插入图片描述
pip list 查看库,无报错显示。

  • 9
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
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 ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值