Python 类型错误:不可损坏的类型:';列表';在google云存储初始化中

Python 类型错误:不可损坏的类型:';列表';在google云存储初始化中,python,google-cloud-platform,google-cloud-storage,Python,Google Cloud Platform,Google Cloud Storage,当我运行一些代码,在它运行了一些非常密集的多处理代码之后,应该只上传几个文件时,我遇到了这个相当模糊的错误。我不能从这个例外中得到什么。我唯一能给出的一点直觉是,这与我们在做这件事之前运行的非常密集的软件有关。我很乐意通过回答问题来澄清任何事情 下面是它在导入行上崩溃的函数 def upload_run_artifacts(run_dir, run_id): print("Uploading run artifacts") from google.cloud import st

当我运行一些代码,在它运行了一些非常密集的多处理代码之后,应该只上传几个文件时,我遇到了这个相当模糊的错误。我不能从这个例外中得到什么。我唯一能给出的一点直觉是,这与我们在做这件事之前运行的非常密集的软件有关。我很乐意通过回答问题来澄清任何事情

下面是它在导入行上崩溃的函数

def upload_run_artifacts(run_dir, run_id):

    print("Uploading run artifacts")
    from google.cloud import storage

    client = storage.Client()
    bucket = client.bucket(ARTIFACTS_BUCKET)
    glob_path = os.path.join(run_dir, "**")
    print(glob_path)
    for f in glob.glob(glob_path):
        print(f)
        print(f"Uploading {f} to run artifacts bucket")
        with open(f, 'rb') as fp:
            rel_path = f.replace(run_dir, str(run_id))
            blob = bucket.blob(rel_path)
            blob.upload_from_file(fp)
这是个例外

Traceback (most recent call last):
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/gerard/Git/captain-benchmarker/captain_benchmarker/benchmark.py", line 396, in <module>
    fire.Fire(
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages/fire/core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages/fire/core.py", line 675, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/Users/gerard/Git/captain-benchmarker/captain_benchmarker/benchmark.py", line 340, in benchmark_autopilot
    upload_run_artifacts(run.id, run_dir)
  File "/Users/gerard/Git/captain-benchmarker/captain_benchmarker/benchmark.py", line 41, in upload_run_artifacts
    from google.cloud import storage
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages/google/cloud/storage/__init__.py", line 34, in <module>
    from pkg_resources import get_distribution
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3262, in <module>
    def _initialize_master_working_set():
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3245, in _call_aside
    f(*args, **kwargs)
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3274, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages/pkg_resources/__init__.py", line 575, in _build_master
    ws = cls()
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages/pkg_resources/__init__.py", line 568, in __init__
    self.add_entry(entry)
  File "/Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages/pkg_resources/__init__.py", line 622, in add_entry
    self.entry_keys.setdefault(entry, [])
TypeError: unhashable type: 'list'

Process finished with exit code 1

您的
sys.path
中可能添加了无效值


如果您已手动在
sys.path
上放置了某些内容(通常不鼓励),请确保这些值仅为,并且它们是有效路径。

安装了哪个版本的
setuptools
python-m pip show setuptools
刚刚更新了我的答案,谢谢!谢谢在你的
上传运行工件
函数开始时,
sys.path
的值是多少?啊!我想你知道了什么。我的路很长。我动态地导入了一个外部Python包,并加入了一点sys path hack来实现这一点。让我试着减少这个,然后再给你回复。再次感谢,是的!这就是问题所在。我的路径被空列表和实际上是文件的东西污染了。如果你能把你的评论转换成答案,我很乐意接受,谢谢!
Name: setuptools
Version: 46.2.0.post20200511
Summary: Easily download, build, install, upgrade, and uninstall Python packages
Home-page: https://github.com/pypa/setuptools
Author: Python Packaging Authority
Author-email: distutils-sig@python.org
License: UNKNOWN
Location: /Users/gerard/miniconda3/envs/benchmarker/lib/python3.8/site-packages
Requires:
Required-by: protobuf, google-auth, google-api-core