import streamlit as st
import pandas as pd
import numpy as np
import requests
import tweepy
import config
import psycopg2
import psycopg2.extras
import plotly.graph_objects as go
auth = tweepy.OAuthHandler(config.TWITTER_CONSUMER_KEY,
config.TWITTER_CONSUMER_SECRET)
auth.set_access_token(config.TWITTER_ACCESS_TOKEN,
config.TWITTER_ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
Problem with my code, it is not running with the twitter key. The module has no attributes
The config module that you are attempting to import and read off of is not what you want.
TWITTER_CONSUMER_KEY and TWITTER_CONSUMER_SECRET are not constants that you can get from a module. These are values that you must input yourself. There is perhaps a piece of code missing at the start of your application that looks like this:
config = {
'TWITTER_CONSUMER_KEY': 'ENTER YOUR TWITTER CONSUMER KEY',
'TWITTER_CONSUMER_SECRET': 'ENTER YOUR TWITTER CONSUMER SECRET'
}
Take a look at this article for more help. Goodluck!
I am trying to connect to a SQL server using Python and then dump the data to google sheets.
import pypyodbc as odbc
import pandas as pd
from google_apis import create_service
when I sun this code block I get an error message
line 1 ModuleNotFound
I have also tried
from Google import Create_Service
import pypyodbc as odbc
import pandas as pd
Can any one help me figure out why.
PLease and thank you.
I am trying to connect to FXCM throuhg an api and am constantly getting an error:
|ERROR|2020-01-11 20:42:41,825|Socket returns an error: ('Connection aborted.', OSError("(10054, 'WSAECONNRESET')")).
The code is :
import fxcmpy
import pandas as pd
from pandas import datetime
from pandas import DataFrame as df
import matplotlib
from pandas_datareader import data as web
import matplotlib.pyplot as plt
import datetime
from datetime import date
import numpy as np
TOKEN = "hidden"
con = fxcmpy.fxcmpy(access_token=TOKEN, log_level='error')
I have been using this for a while now but error suddenly showed up today. How can i fix this?
I got the same problem. I got an email from api#fxcm.com below.
"We did a release on demo on 1/12 to improve the Rest API.
With that said, Our REST API wrapper fxcmpy has been updated, you need to install the latest fxcmpy version at 1.2.6.
Here is the link where you can find the library: https://pypi.org/project/fxcmpy/#files
Please have in mind that just with pip install fxcmpy it might not work as it won’t update the library, please use below command."
pip install –U fxcmpy
from django.template.base import TagHelperNode, VariableNode
ImportError: cannot import name TagHelperNode
I had upgrade Django from 1.8.14 to 1.11.17
It should be:
from django.template.library import TagHelperNode
Reference can be found here.
I am developing a project which has about a dozen different files. At the top of each file I have almost the identical lines which import the same libraries and initializes a connection to my DB:
import re
import urllib2
import datetime
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.sql import *
from sqlalchemy.orm.collections import *
from table_def import Team, Player, Box_Score, Game, Name_Mapper
from datetime import timedelta
from bs4 import BeautifulSoup as bs
from datetime import date, datetime, timedelta
import numpy as np
import argparse
engine = create_engine('sqlite:///ncaaf.db', echo=False)
md = MetaData(bind=engine)
Session = sessionmaker(bind=engine)
s = Session()
teams_table = Table("teams", md, autoload=True)
games_table = Table("games", md, autoload=True)
box_scores_table = Table("box_scores", md, autoload=True)
players_table = Table("players", md, autoload=True)
names_table = Table("names", md, autoload=True)
Can I make a module to import all these modules and to initialize this DB connection? Is that standard? Or dumb for some reason I am not realizing?
When you import something into your module, it becomes available as if it was declared in your module itself. So, you can do what you want like this:
In common_imports.py:
from datetime import date, datetime, timedelta
import numpy as np
import argparse
...
In main_module.py:
from common_import import *
a = np.array([]) # works fine
However this is not recommended since Explicit is better than implicit. E.g. if you do this, someone else (or even you from the future) won't understand where all these imported modules come from. Instead, try to either organize your imports better, or decompose your module into several ones. For example, in your import list I see argparse, SQL stuff and numpy, and I can't imaging single module that may need all these unrelated libraries.
If you create a package, you can import them in the __init__.py file, although I would suggest leaving them where they are to increase code-readability.