安装python torch、transformer、记录

由于安装总是出现各种奇怪问题,现总结帮助以后环境搭建

anaconda promt 命令框

国内常用镜像源

  • 清华大学 :https://pypi.tuna.tsinghua.edu.cn/simple/
  • 阿里云:http://mirrors.aliyun.com/pypi/simple/
  • 中国科学技术大学 :http://pypi.mirrors.ustc.edu.cn/simple/
  • 华中科技大学:http://pypi.hustunique.com/
  • 豆瓣源:http://pypi.douban.com/simple/
  • 腾讯源:http://mirrors.cloud.tencent.com/pypi/simple
  • 华为镜像源:https://repo.huaweicloud.com/repository/pypi/simple/

在base中创建需要的环境:

  • 创建需要的环境,并指定需要的版本
    1. 查看环境目录:conda env list
    2. 创建环境,并指定python版本:conda create –name peculiar python=3.6.9
    3. 激活环境,conda activate peculiar
    4. 查看pip版本:pip show pip 或者 conda list
      最好更新下pip版本,避免出现问题: pip install –upgrade pip
    5. 安装pytorch: 参考链接
      个人觉得下载文件后安装也可以,而且不容易出错
    6. 安装transformers
      如果使用 pip install transformers 安装出现问题,如:
        ERROR: Failed building wheel for tokenizers
      Failed to build tokenizers
      ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects
      
      解决方法:指定transformers版本
      一般用transformers版本3.4.0
      报错:HuggingFace 报错 ImportError: cannot import name ‘HfApi‘
      命令行:
      conda install -c huggingface transformers # 对于python 3.9.13版本
      pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ transformers==3.4.0  #可能出错
      
      测试transformers安装是否成功: python
      	from transformers import pipeline
      	print(pipeline('sentiment-analysis')('we love you'))
      	# 会有一个下载操作
      
  • tree-sitter安装
    • 直接安装使用: pip install tree_sitter -i http://mirrors.aliyun.com/pypi/simple/ –trusted-host mirrors.aliyun.com
      出现超时情况试试加镜像,如果还不可以看看是不是下面的问题
      ERROR: Could not find a version that satisfies the requirement tree_sitter (from versions: none)
      链接
  • sklearn安装
    sklearn安装需要需要先安装
    • Numpy

    • Scipy

    • matpolotlib

      接着安装sklearn,这里需要注意的是在Anaconda中sklearn叫做scikit-learn,并且在安装scikit-learn前还需要安装其他一些依赖,并且最好是按顺序下载
      conda install numpy
      conda install pandas
      conda install scipy
      conda install matplotlib
      conda install scikit-learn==0.20.0
      

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
乘风的头像乘风管理团队
上一篇 2023年8月26日
下一篇 2023年8月26日

相关推荐