簡體   English   中英

Ray 中的錯誤:“ModuleNotFoundError:沒有名為‘pandas’的模塊”

[英]Error in Ray: "ModuleNotFoundError: No module named 'pandas' "

我在名為 p_c 的環境中的終端上啟動了 ray,該環境中安裝了 pandas 命令 ray start --head --num-cpus=2 --num-gpus=0

然后,我運行了以下 python 腳本:

import ray
import os
import pandas as pd
import sys

ray.init(address='auto', redis_password='5241590000000000')

@ray.remote
def foo():
    import pandas as pd
    print("This runs on the VM")
    print(os.getcwd())
    print(sys.path)
    data = pd.read_csv('/Documents/sample.data')
    
    return 1

print("This runs locally")
print(ray.get(foo.remote()))

運行它會引發以下錯誤:

WARNING: Logging before InitGoogleLogging() is written to STDERR
    I1014 13:56:23.410329 16563 16563 global_state_accessor.cc:25] Redis server address = 192.168.29.24:6379, is test flag = 0
    I1014 13:56:23.411886 16563 16563 redis_client.cc:146] RedisClient connected.
    I1014 13:56:23.421353 16563 16563 redis_gcs_client.cc:89] RedisGcsClient Connected.
    I1014 13:56:23.423465 16563 16563 service_based_gcs_client.cc:193] Reconnected to GCS server: 192.168.29.24:37125
    I1014 13:56:23.424247 16563 16563 service_based_accessor.cc:92] Reestablishing subscription for job info.
    I1014 13:56:23.424291 16563 16563 service_based_accessor.cc:422] Reestablishing subscription for actor info.
    I1014 13:56:23.424387 16563 16563 service_based_accessor.cc:797] Reestablishing subscription for node info.
    I1014 13:56:23.424415 16563 16563 service_based_accessor.cc:1073] Reestablishing subscription for task info.
    I1014 13:56:23.424441 16563 16563 service_based_accessor.cc:1248] Reestablishing subscription for object locations.
    I1014 13:56:23.424466 16563 16563 service_based_accessor.cc:1368] Reestablishing subscription for worker failures.
    I1014 13:56:23.424504 16563 16563 service_based_gcs_client.cc:86] ServiceBasedGcsClient Connected.
    This runs locally
    Traceback (most recent call last):
      File "hello1.py", line 26, in <module>
        print(ray.get(foo.remote()))
      File "/home/jatin/.local/lib/python3.8/site-packages/ray/worker.py", line 1538, in get
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(ModuleNotFoundError): ray::__main__.foo() (pid=16182, ip=192.168.29.24)
      File "python/ray/_raylet.pyx", line 479, in ray._raylet.execute_task
      File "hello1.py", line 17, in foo
        import pandas as pd
    ModuleNotFoundError: No module named 'pandas'

我在所有可能的路徑上都安裝了熊貓。 我無法理解工人究竟在哪里尋找它沒有找到的 pandas 模塊。 沒有熊貓導入,代碼運行良好。

Ray 運行時將在配置的虛擬環境中尋找 Pandas。 如果在本地啟動 Ray,請確保在為 Ray 運行時提供服務的虛擬環境中安裝所需的 Python 庫。

例如

. .venv/bin/activate
pip install pandas
ray start --num-cpus=8 --object-store-memory=7000000000 --head

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM