[英]Getting ImportError: No module named azure.storage.blob when doing python manage.py syncdb
When I try to do python manage.py syncdb
in my Django app, I get the error ImportError: No module named azure.storage.blob . 当我尝试在Django应用中执行
python manage.py syncdb
时,出现错误ImportError:没有名为azure.storage.blob的模块 。 But thing is, the following packages are installed if one does pip freeze
: 但事实是,如果进行
pip freeze
则会安装以下软件包:
azure-common==1.0.0 azure-mgmt==0.20.1 azure-mgmt-common==0.20.0 azure-mgmt-compute==0.20.0 azure-mgmt-network==0.20.1 azure-mgmt-nspkg==1.0.0 azure-mgmt-resource==0.20.1 azure-mgmt-storage==0.20.0 azure-nspkg==1.0.0 azure-servicebus==0.20.1 azure-servicemanagement-legacy==0.20.1 azure-storage==0.20.3
Clearly azure-storage is installed, as is evident. 很明显,显然已经安装了天蓝色存储 。 Why is azure.storage.blob not available for import?
为什么azure.storage.blob无法导入? I even went into my
.virtualenvs
directory, and got in all the way to azure.storage.blob
(ie ~/.virtualenvs/myvirtualenv/local/lib/python2.7/site-packages/azure/storage/blob$
). 我什至进入我的
.virtualenvs
目录,并通向azure.storage.blob
(即~/.virtualenvs/myvirtualenv/local/lib/python2.7/site-packages/azure/storage/blob$
)。 It exists! 它存在!
What do I do? 我该怎么办? This answer here has not helped: Install Azure Python api on linux: importError: No module named storage.blob
这里的答案没有帮助: 在Linux上安装Azure Python api:importError:没有名为storage.blob的模块
Note: please ask for more information in case you need it 注意:如果需要,请询问更多信息
I had a similar issue. 我有一个类似的问题。 To alleviate that, I followed this discussion here: https://github.com/Azure/azure-storage-python/issues/51#issuecomment-148151993
为了缓解这种情况,我在这里关注了此讨论: https : //github.com/Azure/azure-storage-python/issues/51#issuecomment-148151993
Basically, try pip install azure==0.11.1
before trying syncdb
, and I'm confident it will work for you! 基本上,在尝试
syncdb
之前尝试pip install azure==0.11.1
,我相信它将为您服务!
There is a thread similar with yours, please check my answer for the thread Unable to use azure SDK in Python . 有一个与您相似的线程,请检查我的答案以了解无法在Python中使用azure SDK的线程。
Based on my experience, Python imports the third-party library packages from some library paths that you can check them thru codes import sys
& sys.path
in the python interpreter. 根据我的经验,Python从某些库路径中
import sys
第三方库包,您可以通过代码在python解释器中import sys
& sys.path
来检查它们。 So you can try to dynamically add the new path contains the installed azure
packages into the sys.path
in the Python runtime to solve the issue. 因此,您可以尝试在Python运行时中将包含已安装的
azure
软件包的新路径动态添加到sys.path
中,以解决此问题。 For adding the new library path, you just code sys.path.append('<the new paths you want to add>')
at the front of the code like import azure
. 要添加新的库路径,您只需在代码的
sys.path.append('<the new paths you want to add>')
如import azure
sys.path.append('<the new paths you want to add>')
编写sys.path.append('<the new paths you want to add>')
。
If the way has not helped, I suggest you can try to reinstall Python environment. 如果该方法没有帮助,建议您尝试重新安装Python环境。 On Ubuntu, you can use the command
sudo apt-get remove python python-pip
& sudo apt-get install python python-pip
to reinstall Python 2.7
& pip 2.7
.(Note: The current major Linux distributions use Python 2.7 as the system default version.) 在Ubuntu上,您可以使用命令
sudo apt-get remove python python-pip
和sudo apt-get install python python-pip
重新安装Python 2.7
和pip 2.7
。(注意:当前的主要Linux发行版使用Python 2.7作为系统默认值版。)
If Python 3.4 as your runtime for Django, the apt package names for Ubuntu are python3
and python3-pip
, and you can use sudo pip3 install azure
for Python 3.4
on Ubuntu. 如果将Python 3.4作为Django的运行时,则Ubuntu的apt软件包名称为
python3
和python3-pip
,并且您可以在Ubuntu上使用sudo pip3 install azure
for Python 3.4
。
Any concern, please feel free to let me know. 如有任何疑问,请随时告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.