我正在尝试在我的python应用程序中使用Azure Storage Emulator,但收到以下错误:
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 . . .
有什么想法吗?
答案 0 :(得分:1)
在一个模块中将变量声明为全局变量不会让其他模块可见。
为了解决您的具体问题,看起来这可能是一段时间前已修复的known issue。您是否拥有最新版本的azure存储模块?