当pip安装GoogleAppEngineCloudStorageClient,<your_app_directory> 是什么?

2024-05-26 04:23:41 发布

您现在位置:Python中文网/ 问答频道 /正文

按照安装说明here操作时,^{中的<your_app_directory>是什么

pip install GoogleAppEngineCloudStorageClient -t <your_app_directory/lib>

是吗?在

我试过:

  1. /应用程序文件夹
  2. 我在GAE上运行的托管我的.py文件的主文件夹
  3. 与venv子文件夹下的(2)相同

但是我得到了:

ImportError:没有名为cloudstorage的模块

如果我尝试:

^{pr2}$

以及:

重要错误:没有命名的模块lib.云存储在

如果我尝试:

import lib.cloudstorage as gcd

所有这些。在

例如

>>> os.listdir("/applications/lib") 
['cloudstorage', 'GoogleAppEngineCloudStorageClient-1.9.15.0-py2.7.egg-info']
>>> import lib.cloudstorage 
Traceback (most recent call last):   
File "<stdin>", line 1, in <module> ImportError: No module named lib.cloudstorage
>>>

Tags: 模块installpipimport文件夹app应用程序your
2条回答

<your_app_directory>是包含app.yaml文件的文件夹的路径。在

YAML文件指定一个包含GAE handlers的脚本文件。此脚本文件、YAML文件和依赖项需要打包到upload的文件夹中。在

我使用这个文件夹结构:

  • 应用程序/
    • 在应用程序yamlNote: script attribute will point to src.main.application
    • src公司/
      • __init__.py
      • 在主.pyContains a variable called application
    • 我的包/
      • __init__.py
      • 在超级模块.py在
      • 在其他模块.py在
    • 图书馆/
      • 云存储/
      • 其他库/
      • 等等/

为了帮助python在子文件夹中查找模块,比如使用import cloudstorage as gcs,以下代码在main.py文件中很有用:

import os
import sys
#sys.path.append(os.path.join(os.path.dirname(__file__), "lib"))
sys.path.append(os.path.join(os.path.join(os.path.dirname(__file__), ".."), "lib"))  # relative to main.py

我不确定最后是不是这样做的,但在执行以下操作后,我不再收到导入错误:

sys.path.append('/applications/lib')

相关问题 更多 >