Paddle 导入paddle报错

7hiiyaii  于 2022-10-22  发布在  其他
关注(0)|答案(3)|浏览(310)

环境:

Ubuntu 20.04 64位操作系统

安装的是CPU版本

安装命令:

python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple

conda install paddlepaddle --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/

两个都试过了,均能够安装成功且不报错。

安装成功测试:

$ pip show paddlepaddle
Name: paddlepaddle
Version: 2.1.1
Summary: Parallel Distributed Deep Learning
Home-page: UNKNOWN
Author: None
Author-email: Paddle-better@baidu.com
License: Apache Software License
Location: /home/jinhl/anaconda3/envs/py38/lib/python3.8/site-packages
Requires: Pillow, protobuf, gast, astor, decorator, numpy, six, requests
Required-by:

但是导入之后还是报错了。

报错如下:

Python 3.8.5 (default, Sep  4 2020, 07:30:14) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddle
Traceback (most recent call last):
  File "/home/jinhl/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/home/jinhl/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/home/jinhl/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: PyCapsule_Import could not import module "datetime"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jinhl/anaconda3/envs/py38/lib/python3.8/site-packages/paddle/__init__.py", line 25, in <module>
    from .fluid import monkey_patch_variable
  File "/home/jinhl/anaconda3/envs/py38/lib/python3.8/site-packages/paddle/fluid/__init__.py", line 36, in <module>
    from . import framework
  File "/home/jinhl/anaconda3/envs/py38/lib/python3.8/site-packages/paddle/fluid/framework.py", line 29, in <module>
    import numpy as np
  File "/home/jinhl/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/__init__.py", line 140, in <module>
    from . import core
  File "/home/jinhl/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.8 from "/home/jinhl/anaconda3/envs/py38/bin/python"
  * The NumPy version is: "1.19.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: PyCapsule_Import could not import module "datetime"
jaql4c8m

jaql4c8m1#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看 官网API文档常见问题历史IssueAI社区 来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

wgx48brx

wgx48brx2#

看起来是numpy的包版本问题

643ylb08

643ylb083#

升级到numpy 1.21.1 之后,paddle可以正常用了。

相关问题