0

我正在尝试在我的 python 应用程序中使用Azure 存储模拟器,但出现以下错误:

from azure.storage.table import TableService, Entity

#Added after error
global DEV_ACCOUNT_NAME
DEV_ACCOUNT_NAME = "devstoreaccount1"

table_service = TableService(account_name='devstoreaccount1', account_key='Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',)

table_service.use_local_storage = True
table_service.is_emulated = True

table_service.create_table("test")

错误:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensio
ns\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_util.py", line 7
6, in exec_file
    exec(code_obj, global_variables)
  File "c:\ScratchApp\ScratchApp.py", line 17, in <module>
    table_service.create_table("test")
  File "C:\Python27\lib\site-packages\azure\storage\table\tableservice.py", line
 274, in create_table
    request, self.use_local_storage)
  File "C:\Python27\lib\site-packages\azure\storage\_common_serialization.py", l
ine 212, in _update_request_uri_query_local_storage
    return '/' + DEV_ACCOUNT_NAME + uri, query
NameError: global name 'DEV_ACCOUNT_NAME' is not defined
Press any key to continue . . .

有任何想法吗?

4

1 回答 1

1

在一个模块中将变量声明为全局变量不会神奇地使其对其他模块可见。

但是,为了解决您的特定问题,这看起来可能是前一段时间已修复的已知问题。你有最新版本的 azure 存储模块吗?

于 2016-05-27T22:26:24.093 回答