当前位置: 首页 > news >正文

paddleNLP 安装

@创建于:2022.10.18
@修改于:2022.10.18

文章目录

    • 1、报错信息
    • 2、解决办法
    • 3、问题报错
    • 4、import paddleNLP报错 ModuleNotFoundError: No module named 'paddle'

截止到2022年10月18日,paddlenlp==2.4.1是最新的版本。
具体参考 安装PaddleNLP

下面是在
linux CentOS Linux release 7.9.2009 (Core)
Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020
环境下安装的

1、报错信息

conda create -n paddlenlp python=3.7
conda activate paddlenlp
pip install paddlenlp==2.4.1

安装paddlenlp==2.4.1的报错信息如下:

(paddlenlp) [root@szzf16 ~]# pip install paddlenlp==2.4.1
Looking in indexes: http://192.168.144.6/pypi/
Collecting paddlenlp==2.4.1
  Downloading http://192.168.144.6/packages/1f/54/6d5ae82c9a4556daf18334a07d8dd4612b586b4bd4629bcd82099cccf20d/paddlenlp-2.4.1-py3-none-any.whl (1.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.9/1.9 MB 68.6 MB/s eta 0:00:00
Collecting datasets>=2.0.0
  Downloading http://192.168.144.6/packages/7c/75/d282907e7ebd87e4b3475bc5156140465372fa451bc6cbddbefa54915d00/datasets-2.6.1-py3-none-any.whl (441 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 441.9/441.9 kB 2.2 MB/s eta 0:00:00
Collecting tqdm
  Downloading http://192.168.144.6/packages/47/bb/849011636c4da2e44f1253cd927cfb20ada4374d8b3a4e425416e84900cc/tqdm-4.64.1-py2.py3-none-any.whl (78 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.5/78.5 kB 1.8 MB/s eta 0:00:00
Collecting colorama
  Downloading http://192.168.144.6/packages/77/8b/7550e87b2d308a1b711725dfaddc19c695f8c5fa413c640b2be01662f4e6/colorama-0.4.5-py2.py3-none-any.whl (16 kB)
Collecting paddlefsl
  Downloading http://192.168.144.6/packages/fb/4a/25d1959a8f1fe5ee400f32fc9fc8b56d4fd6fc25315e23c0171f6e705e2a/paddlefsl-1.1.0-py3-none-any.whl (101 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 101.0/101.0 kB 1.8 MB/s eta 0:00:00
Collecting paddle2onnx
  Downloading http://192.168.144.6/packages/7e/c1/a4ca95dc6a23c96386497402cad911ff0b096539743bcca1d7e46ae2010f/paddle2onnx-1.0.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.0/3.0 MB 1.1 MB/s eta 0:00:00
Collecting visualdl
  Downloading http://192.168.144.6/packages/8a/e5/940426714a10c916466764eaea51ab7e10bd03896c625fcc4524a0855175/visualdl-2.4.1-py3-none-any.whl (4.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.9/4.9 MB 2.2 MB/s eta 0:00:00
Collecting seqeval
  Downloading http://192.168.144.6/packages/9d/2d/233c79d5b4e5ab1dbf111242299153f3caddddbb691219f363ad55ce783d/seqeval-1.2.2.tar.gz (43 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.6/43.6 kB 10.4 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [36 lines of output]
      WARNING: The repository located at 192.168.144.6 is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host 192.168.144.6'.
      ERROR: Could not find a version that satisfies the requirement setuptools_scm (from versions: none)
      ERROR: No matching distribution found for setuptools_scm
      /usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages/setuptools/installer.py:30: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
        SetuptoolsDeprecationWarning,
      Traceback (most recent call last):
        File "/usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages/setuptools/installer.py", line 82, in fetch_build_egg
          subprocess.check_call(cmd)
        File "/usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/subprocess.py", line 363, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/usr/local/Anaconda3/envs/paddlenlp/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpywcw3z3z', '--quiet', 'setuptools_scm']' returned non-zero exit status 1.
      
      The above exception was the direct cause of the following exception:
      
      Traceback (most recent call last):
        File "<string>", line 36, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-zym8w4i4/seqeval_3c49057ca4f7471798ccb995825ae407/setup.py", line 56, in <module>
          'Programming Language :: Python :: Implementation :: PyPy'
        File "/usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages/setuptools/__init__.py", line 86, in setup
          _install_setup_requires(attrs)
        File "/usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages/setuptools/__init__.py", line 80, in _install_setup_requires
          dist.fetch_build_eggs(dist.setup_requires)
        File "/usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages/setuptools/dist.py", line 878, in fetch_build_eggs
          replace_conflicting=True,
        File "/usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages/pkg_resources/__init__.py", line 791, in resolve
          replace_conflicting=replace_conflicting
        File "/usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1075, in best_match
          return self.obtain(req, installer)
        File "/usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1087, in obtain
          return installer(requirement)
        File "/usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages/setuptools/dist.py", line 945, in fetch_build_egg
          return fetch_build_egg(self, req)
        File "/usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages/setuptools/installer.py", line 84, in fetch_build_egg
          raise DistutilsError(str(e)) from e
      distutils.errors.DistutilsError: Command '['/usr/local/Anaconda3/envs/paddlenlp/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpywcw3z3z', '--quiet', 'setuptools_scm']' returned non-zero exit status 1.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
(paddlenlp) [root@szzf16 ~]#

2、解决办法

ERROR: Could not find a version that satisfies the requirement setuptools_scm (from versions: none)

根据错误提示,查找发现缺少 setuptools_scm 包

(paddlenlp) [root@szzf16 ~]# conda list setuptools
# packages in environment at /usr/local/Anaconda3/envs/paddlenlp:
#
# Name                    Version                   Build  Channel
setuptools                63.4.1           py37h06a4308_0  
(paddlenlp) [root@szzf16 ~]# conda list setuptools_scm
# packages in environment at /usr/local/Anaconda3/envs/paddlenlp:
#
# Name                    Version                   Build  Channel
(paddlenlp) [root@szzf16 ~]# 

因为 pip install setuptools_scm 报错.

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

使用 conda命令 进行包的安装,版本为setuptools_scm==7.0.4。具体如下:

(paddlenlp) [root@szzf16 ~]# pip install setuptools_scm
Looking in indexes: http://192.168.144.6/pypi/
Requirement already satisfied: setuptools_scm in /usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages (7.0.5)
Requirement already satisfied: setuptools in /usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages (from setuptools_scm) (63.4.1)
Requirement already satisfied: typing-extensions in /usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages (from setuptools_scm) (4.4.0)
Requirement already satisfied: tomli>=1.0.0 in /usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages (from setuptools_scm) (2.0.1)
Requirement already satisfied: packaging>=20.0 in /usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages (from setuptools_scm) (21.3)
Requirement already satisfied: importlib-metadata in /usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages (from setuptools_scm) (5.0.0)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages (from packaging>=20.0->setuptools_scm) (3.0.9)
Requirement already satisfied: zipp>=0.5 in /usr/local/Anaconda3/envs/paddlenlp/lib/python3.7/site-packages (from importlib-metadata->setuptools_scm) (3.9.0)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

(paddlenlp) [root@szzf16 ~]# conda install setuptools_scm
(paddlenlp) [root@szzf16 ~]# conda list setuptools_scm
# packages in environment at /usr/local/Anaconda3/envs/paddlenlp:
#
# Name                    Version                   Build  Channel
setuptools_scm            7.0.4                hd3eb1b0_0  
(paddlenlp) [root@szzf16 ~]# 

3、问题报错

paddlenlp包顺利下载,但是无法安装,报出如下错误。

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

该如何做呢?

4、import paddleNLP报错 ModuleNotFoundError: No module named ‘paddle’

(paddlenlp) C:\Windows\system32>python
Python 3.7.10 | packaged by conda-forge | (default, Oct 13 2021, 20:21:52) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddlenlp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\ProgramData\Anaconda3\envs\paddlenlp\lib\site-packages\paddlenlp\__init__.py", line 24, in <module>
    from . import data
  File "D:\ProgramData\Anaconda3\envs\paddlenlp\lib\site-packages\paddlenlp\data\__init__.py", line 15, in <module>
    from .collate import *
  File "D:\ProgramData\Anaconda3\envs\paddlenlp\lib\site-packages\paddlenlp\data\collate.py", line 17, in <module>
    import paddle
ModuleNotFoundError: No module named 'paddle'
>>> exit()

这是因为没有安装 paddlepaddle

pip install paddlepaddle

(paddlenlp) C:\Windows\system32>python
Python 3.7.10 | packaged by conda-forge | (default, Oct 13 2021, 20:21:52) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddlenlp
>>>

安装完paddlepaddle后,可以成功import paddlenlp

相关文章:

  • 笔记:编写程序,分别采用面向对象和 pyplot 快捷函数的方式绘制正弦曲线 和余弦曲线。 提示:使用 sin()或 cos()函数生成正弦值或余弦值。
  • 【算法】人工蜂群算法,解决多目标车间调度问题,柔性车间调度问题
  • 训练深度神经网络,使用反向传播算法,产生梯度消失和梯度爆炸问题的原因?
  • 程序员学CFA——数量分析方法(四)
  • 2024年好用又便宜的云手机!哪款性价比高?
  • 【自然语言处理】InstructGPT、GPT-4 概述
  • 逆向案例二:关键字密文解密,自定义的加密解密。基于企名片科技的爬取。
  • 计算机网络-网络互联
  • 同源不同页面之间的通信,SharedWorker使用
  • 【论文解读】transformer小目标检测综述
  • 数据结构:链表的冒泡排序
  • 【高德地图】Android高德地图控件交互详细介绍
  • 【算法笔记】位运算详解
  • 《设计模式》装饰者模式
  • SpringBoot--在Entity(DAO)中使用枚举类型
  • Session(服务端会话跟踪技术)
  • CVPR2022 BatchFormer
  • EXCEL中ADDRESS函数的使用
  • libtorch c++ 搭建分类网络进行训练和预测
  • 初学前端-JavaScript(语法)
  • Hold the door!protobuf从PC到STM32的互相通信
  • 【allegro 17.2软件操作保姆级教程一】软件操作环境设置
  • Python基础内容训练11(面向对象进阶)
  • 不要小看get post的区别
  • 32.(前端)主页布局
  • 【Python】9*9乘法口诀表(while、for两种循环)
  • React中组件通信有哪些方式
  • Redux简单使用
  • 【PyTorch深度学习项目实战100例】—— 基于Conv3D实现三维立体MNIST数据集分类 | 第54例
  • 当心!你的App 可能是山寨的
  • 前端面试问题(5)
  • 十年网安行业代表性案例出炉,中睿天下Web攻击溯源案例实力入选