Skip to content

安装后导包报错 #25609

Closed
Closed
@reeselaye

Description

@reeselaye

import paddle.fluid as fluid
Traceback (most recent call last):
File "", line 1, in
File "/home/actor/.local/lib/python3.5/site-packages/paddle/init.py", line 35, in
batch = batch.batch
NameError: name 'batch' is not defined

Activity

Aurelius84

Aurelius84 commented on Jul 20, 2020

@Aurelius84
Contributor

请问您使用的paddle版本是哪个?

luoqishuai

luoqishuai commented on Aug 4, 2020

@luoqishuai
[root@localhost ~]# pip3 install LAC -i https://pypi.douban.com/simple/
Looking in indexes: https://pypi.douban.com/simple/
Requirement already satisfied: LAC in /usr/local/python3/lib/python3.6/site-packages (2.0.4)
Requirement already satisfied: paddlepaddle>=1.6 in /usr/local/python3/lib/python3.6/site-packages (from LAC) (1.8.3)
Requirement already satisfied: opencv-python in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (4.3.0.36)
Requirement already satisfied: Pillow in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (7.2.0)
Requirement already satisfied: protobuf>=3.1.0 in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (3.12.2)
Requirement already satisfied: graphviz in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (0.14.1)
Requirement already satisfied: six in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (1.14.0)
Requirement already satisfied: pathlib in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (1.0.1)
Requirement already satisfied: scipy<=1.3.1; python_version >= "3.5" in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (1.3.1)
Requirement already satisfied: nltk; python_version >= "3.5" in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (3.5)
Requirement already satisfied: matplotlib; python_version >= "3.6" in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (3.2.1)
Requirement already satisfied: prettytable in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (0.7.2)
Requirement already satisfied: objgraph in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (3.4.1)
Requirement already satisfied: rarfile in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (4.0)
Requirement already satisfied: numpy>=1.12; python_version >= "3.5" in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (1.18.2)
Requirement already satisfied: pyyaml in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (5.3.1)
Requirement already satisfied: funcsigs in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (1.0.2)
Requirement already satisfied: astor in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (0.8.1)
Requirement already satisfied: requests>=2.20.0 in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (2.23.0)
Requirement already satisfied: decorator in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (4.4.2)
Requirement already satisfied: gast>=0.3.3 in /usr/local/python3/lib/python3.6/site-packages (from paddlepaddle>=1.6->LAC) (0.3.3)
Requirement already satisfied: setuptools in /usr/local/python3/lib/python3.6/site-packages (from protobuf>=3.1.0->paddlepaddle>=1.6->LAC) (41.0.0)
Requirement already satisfied: joblib in /usr/local/python3/lib/python3.6/site-packages (from nltk; python_version >= "3.5"->paddlepaddle>=1.6->LAC) (0.14.1)
Requirement already satisfied: regex in /usr/local/python3/lib/python3.6/site-packages (from nltk; python_version >= "3.5"->paddlepaddle>=1.6->LAC) (2020.4.4)
Requirement already satisfied: click in /usr/local/python3/lib/python3.6/site-packages (from nltk; python_version >= "3.5"->paddlepaddle>=1.6->LAC) (7.1.1)
Requirement already satisfied: tqdm in /usr/local/python3/lib/python3.6/site-packages (from nltk; python_version >= "3.5"->paddlepaddle>=1.6->LAC) (4.45.0)
Requirement already satisfied: cycler>=0.10 in /usr/local/python3/lib/python3.6/site-packages (from matplotlib; python_version >= "3.6"->paddlepaddle>=1.6->LAC) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/python3/lib/python3.6/site-packages (from matplotlib; python_version >= "3.6"->paddlepaddle>=1.6->LAC) (1.2.0)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/python3/lib/python3.6/site-packages (from matplotlib; python_version >= "3.6"->paddlepaddle>=1.6->LAC) (2.8.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/python3/lib/python3.6/site-packages (from matplotlib; python_version >= "3.6"->paddlepaddle>=1.6->LAC) (2.4.7)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/python3/lib/python3.6/site-packages (from requests>=2.20.0->paddlepaddle>=1.6->LAC) (2.9)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/python3/lib/python3.6/site-packages (from requests>=2.20.0->paddlepaddle>=1.6->LAC) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/python3/lib/python3.6/site-packages (from requests>=2.20.0->paddlepaddle>=1.6->LAC) (2020.4.5.1)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/python3/lib/python3.6/site-packages (from requests>=2.20.0->paddlepaddle>=1.6->LAC) (1.25.9)
WARNING: You are using pip version 20.0.2; however, version 20.2 is available.
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-76-f90a347430d9> in <module>
     18 import html,os
     19 import copy
---> 20 from LAC import LAC
     21 # import affinity

/usr/local/python3/lib/python3.6/site-packages/LAC/__init__.py in <module>
     21 version_info = (2, 0, 4, 0)
     22 
---> 23 from .lac import LAC

/usr/local/python3/lib/python3.6/site-packages/LAC/lac.py in <module>
     26 
     27 import numpy as np
---> 28 import paddle.fluid as fluid
     29 from paddle.fluid.core import PaddleTensor
     30 from paddle.fluid.core import AnalysisConfig

/usr/local/python3/lib/python3.6/site-packages/paddle/__init__.py in <module>
     33 import paddle.compat
     34 import paddle.distributed
---> 35 batch = batch.batch
     36 import paddle.sysconfig
     37 import paddle.complex

NameError: name 'batch' is not defined

Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
LAC 2.0.4 ,paddlepaddle 1.8.3 ,centos 7,
请问该怎么解决呢?
@Aurelius84

luoqishuai

luoqishuai commented on Aug 4, 2020

@luoqishuai

已解决

该问题最开始是 linux 的lib包不对
https://blog.csdn.net/qq_24798295/article/details/90240666
在安装完一个包后 (如libSM.so.6)
再次在原有jupyter notebook的代码块中导入,会报NameError: name 'batch' is not defined.
关闭ipynb文件后,重新启动,导入,会报下一个包错误 如 (libXrender.so.1)

三个包全部安装完后,关闭ipynb文件后,重新启动,导入. 无异常.

paddle-bot-old

paddle-bot-old commented on Apr 12, 2021

@paddle-bot-old

Are you satisfied with the resolution of your issue?

YES
No

makaspacex

makaspacex commented on Apr 22, 2021

@makaspacex

image

这是我的解决办法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Aurelius84@gongweibao@makaspacex@reeselaye@luoqishuai

        Issue actions

          安装后导包报错 · Issue #25609 · PaddlePaddle/Paddle