【ArcGISpro】克隆python环境导入pandas及geopandas报错:TypeError: expected string or bytes-like object解决方法

项目场景:

在ArcGISpro克隆的python环境下使用第三方库pandas及geopandas


问题描述

ArcGISpro克隆的python环境使用第三方库pandas报错,报错内容如下:

Traceback (most recent call last):
  File "E:/编程文件python/pythonProject/合并excel表格工具.py", line 12, in <module>
    import pandas
  File "E:\编程文件python\arcgispro_Python_clone\arcgispro-py3-clone1\lib\site-packages\pandas\__init__.py", line 22, in <module>
    from pandas.compat import (
  File "E:\编程文件python\arcgispro_Python_clone\arcgispro-py3-clone1\lib\site-packages\pandas\compat\__init__.py", line 23, in <module>
    from pandas.compat.pyarrow import (
  File "E:\编程文件python\arcgispro_Python_clone\arcgispro-py3-clone1\lib\site-packages\pandas\compat\pyarrow.py", line 9, in <module>
    _palv = Version(_pa_version)
  File "E:\编程文件python\arcgispro_Python_clone\arcgispro-py3-clone1\lib\site-packages\pandas\util\version\__init__.py", line 339, in __init__
    match = self._regex.search(version)
TypeError: expected string or bytes-like object

原因分析:

分析:错位定位至match = self._regex.search(version)version变量,根据备注方法备注# Validate the version and parse it into pieces(# 验证版本并将其解析为多个部分),该方法用于版本验证

#修改前
class Version(_BaseVersion):

    _regex = re.compile(r"^\s*" + VERSION_PATTERN + r"\s*$", re.VERBOSE | re.IGNORECASE)

    def __init__(self, version: str) -> None:

        # Validate the version and parse it into pieces
        match = self._regex.search(version)

解决方案:

解决方法:既然匹配不到就自己给呗,打开pro->python->查看pandas的版本号,嗯是1.2.3,好,值填上吧。

#修改后
class Version(_BaseVersion):

    _regex = re.compile(r"^\s*" + VERSION_PATTERN + r"\s*$", re.VERBOSE | re.IGNORECASE)

    def __init__(self, version: str) -> None:

        # Validate the version and parse it into pieces
        match = self._regex.search('1.2.3')

你可能感兴趣的:(arcgispro,bug,pandas,python,开发语言,pycharm)