简体   繁体   English

即使正确安装,导入包也会出错

[英]Import package error even though it is properly installed

I have installed EventBrite API for my django application.我已经为我的 django 应用程序安装了EventBrite API The main purpose here is to add event details from the site into my database.这里的主要目的是将站点中的event详细信息添加到我的数据库中。

Since this script will run periodically I have added this into management/commands folder.由于此脚本将定期运行,因此我已将其添加到 management/commands 文件夹中。 See the below pic, file name is eventbrite见下图,文件名是eventbrite

在此处输入图片说明

Problem is when I execute my script using python manage.py eventbrite , it is showing ImportError: cannot import name Eventbrite but I have already installed this package inside my virtual environment .问题是当我使用python manage.py eventbrite执行我的脚本时,它显示ImportError: cannot import name Eventbrite但我已经在我的virtual environment安装了这个包。

pip freeze

Django==1.9.2
eventbrite==3.3.3
requests==2.9.1
wheel==0.24.0

When I execute the same package in Django Shell , it is not showing any error当我在Django Shell执行相同的包时,它没有显示任何错误

python manage.py shell
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from eventbrite import Eventbrite
>>> 

Could anyone tell me why it is showing an import error when I run the script using python manage.py eventbrite ?谁能告诉我为什么当我使用python manage.py eventbrite运行脚本时显示import error

It looks like you might have a naming conflict between the eventbrite package loaded from pip, and the eventbrite module in your management command.看起来您可能在从 pip 加载的eventbrite包和管理命令中的eventbrite模块之间存在命名冲突。 How are you importing EventBrite from within your script?您如何从脚本中导入EventBrite If you're doing from eventbrite import Eventbrite , then it will try to load it from your own module when using the project interpreter and not find the class.如果您正在执行from eventbrite import Eventbrite ,那么它会在使用项目解释器时尝试从您自己的模块加载它并且找不到类。 Easy solution would be to name your command something other than eventbrite .简单的解决方案是将您的命令命名为eventbrite以外的其他名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使安装正确,也无法导入pmdarima - Can't import pmdarima even though it's installed properly 无法导入 Azure 存储 Blob package 即使已安装 - Cannot import Azure Storage Blob package even though it is installed 即使正确安装,VS代码中的Python模块错误 - Python module error in vs code even though installed properly 导入 numpy 时出错,即使我安装正确 - Error importing numpy even though I installed it properly pip无法正常运行,即使已正确安装 - pip is not working , even though it is properly installed 未找到模块,即使安装了 package 'graphviz' - Module not found, even though the package 'graphviz' is installed 即使安装成功,也无法导入 sklearn - cannot import sklearn even though it is installed successfully 即使安装了 pygame 也无法导入 - Can't import pygame even though it is installed 即使安装了 PySerial 也无法导入 - Can not import PySerial even though it's installed pyautogui / pyscreeze 找不到枕头,即使它已成功安装到同一个 package 文件夹中,我可以导入它 - pyautogui / pyscreeze can't find pillow even though it is successfully installed into the same package folder and I can import it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM