简体   繁体   中英

Import package error even though it is properly installed

I have installed EventBrite API for my django application. The main purpose here is to add event details from the site into my database.

Since this script will run periodically I have added this into management/commands folder. See the below pic, file name is 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 .

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

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 ?

It looks like you might have a naming conflict between the eventbrite package loaded from pip, and the eventbrite module in your management command. How are you importing EventBrite from within your script? 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. Easy solution would be to name your command something other than eventbrite .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM