pycharm上面简单的python代码运行报错怎么解决?貌似是pycharm的环境没有配置好,跪求大神指点!

各位大神好:
本人是一枚python初学者,最近在练习编码的时候用的是pycharm,同样写了一段简单的代码,就是把两个表格进行拼接合并,pandas库也进行了安装,写好之后,在pycharm上运行,一堆报错的,但是在其他程序上代码是可以正常运行的,感觉像是哪的环境没有搭配好。
自己也尝试了百度搜索答案,在pycharm里面配置了本地的python程序,可是还是不行。期望各位大神和老师有空了能给些指点!非常感谢了。
图片说明

    代码如下:
    #data1和data2两个表格进行拼接合并

import pandas as pd
data1 = pd.read_excel(
r"C:\Users\cui\Desktop\测试\2\客户资金对帐2019601-20190619_001.xlsx",
sheet_name=0,
header=0,
dtype='str')
data2 = pd.read_excel(
r"C:\Users\cui\Desktop\测试\2\客户资金对帐2019601-20190619_002.xlsx",
sheet_name=0,
header=0,
dtype='str')
data3 = pd.concat([data1, data2])
data3.to_excel(excel_writer=r"C:\Users\cui\Desktop\测试\汇总输出\huizong.xlsx")

![图片说明](https://img-ask.csdn.net/upload/201906/25/1561425996_709591.png)


报错的代码如下:报错的内容比写的代码都长
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
runfile('C:/Users/cui/PycharmProjects/untitled/ceshi1.py', wdir='C:/Users/cui/PycharmProjects/untitled')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/cui/PycharmProjects/untitled/ceshi1.py", line 2, in <module>
    import pandas as pd
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\cui\.virtualenvs\untitled\lib\site-packages\pandas\__init__.py", line 42, in <module>
    from pandas.core.api import *
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\cui\.virtualenvs\untitled\lib\site-packages\pandas\core\api.py", line 7, in <module>
    from pandas.core.arrays.integer import (
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\cui\.virtualenvs\untitled\lib\site-packages\pandas\core\arrays\__init__.py", line 2, in <module>
    from .base import (ExtensionArray,    # noqa
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\cui\.virtualenvs\untitled\lib\site-packages\pandas\core\arrays\base.py", line 21, in <module>
    from pandas.core import ops
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\cui\.virtualenvs\untitled\lib\site-packages\pandas\core\ops.py", line 16, in <module>
    from pandas._libs import algos as libalgos, lib, ops as libops
ImportError: cannot import name 'ops' from 'pandas._libs' (C:\Users\cui\.virtualenvs\untitled\lib\site-packages\pandas\_libs\__init__.py)

图片说明

图片说明

2个回答

把pycharm全部卸载了重新安装,然后先安装第三方库,再运行代码,就能正常运行了。谢谢老师指点

找不到 pandas._libs的ops模块属性,可能是你的pandas的安装有问题,建议把pandas卸载在重新安装一下

weixin_43072440
星梦月缘 谢谢老师,重新安装库,安装成功之后,还是报错,于是就索性把pycharm全部卸载了重新安装,然后先安装第三方库,再运行代码,就能正常运行了。谢谢老师指点
7 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问