Reputation: 454
I'm trying to import a class Parser
from a file parser.py
in the same directory. However I keep getting the following error whenever I try to instantiate a Parser object:
File "bot.py", line 4, in <module>
from parser import Parser
ImportError: cannot import name Parser
I'm instantiating the object in the following way:
parser = Parser();
The same script works at my friend's setup so I'm not sure if it's a problem with the code. my version of python is 2.7.13. I'm including the imports below:
bot.py
:
from parser import Parser
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import logging
import csv
import os, sys, types
from random import randint
import urllib2
import json
import string
from bs4 import BeautifulSoup
import requests
parser.py:
import re
class Parser:
.....
##parser stufff
Upvotes: 0
Views: 42
Reputation: 71
Did you try passing a relative path like
from .parser import Parser
Upvotes: 1