Hoping someone has some experience with the Alpaca API. I have installed using pip install alpaca-trade-api, and also pip3 install alpaca-trade-api.
What I do not understand is that I can install alpaca trade API, but not the specific module.
import alpaca_trade_api as tradeapi
This bit runs. But the below doesn't
from alpaca_trade_api import StreamConn
As it returns
cannot import name 'StreamConn' from 'alpaca_trade_api'
Thanks in advance! :)
Related
I'm trying to do a personal project for my portfolio, I would like to scrape the tweets about the president Macron but I get this error with twitterscrapper.
from twitterscraper import query_tweets
import datetime as dt
import pandas as pd
begin_date=dt.date(2020,11,18)
end_date=dt.date(2020,11,19)
limit=1000
lang='English'
tweets=query_tweets("#macron",begindate=begin_date,enddate=end_date,limit=limit,lang=lang)
Error:
TypeError: query_tweets() got an unexpected keyword argument 'begindate'
May I know how to solve it?
The code is fine, the problem is that you installed the outdated version of twitterscraper.
You may update your package by using pip install twitterscraper --upgrade
or
pip install twitterscraper==1.6.1 to ensure it is the latest
I've build a Function in Azure and deployed it via VS.
The function is running locally well, the build process when uploaded to the cloud is successfull but when it's trying to run (with the blob trigger) I get the next error:
ImportError: Unable to import required dependencies: numpy
I'm using pandas library that needs numpy.
I downloaded all of the packeges and dependencies,I've tried to uninstall and install again ,I even tried to upgrade every library especially numpy, nothing.
The function is written in Python 3.7.5 and running on Linux env(Azure runtime).
my imports:
import logging
import openpyxl
import pymysql
import pymysql.cursors
import pandas as pd
import xlrd
import re
from itertools import islice
import azure.functions as func
You need to have all your dependencies in requirements.txt before you publish. This way (using the new tools), after publish all your application dependencies will be downloaded for you as part of your function app content.
In this case, please make sure you have pandas, numpy or whatever is required by your application in the requirements.txt file.
Here's more information on how to publish and what to expect -- https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python#publishing-to-azure
Please check if your deployed azure function content is correct. You can do that with App Service Editor in the portal.
I want to integrate Slack alert messages when a task fail in Airflow with SlackWebHookOperator. I have issue with the import of the operator.
In this tutorial (https://medium.com/datareply/integrating-slack-alerts-in-airflow-c9dcd155105) the author mentions there are 2 ways to achieve this. The first implementation is using slack legacy tokens which can be deprecated anytime and the second is using slack webhook which is the implementation I want. The author mentions to install slack dependencies, quoted by the author "Remember to install slack dependencies pip install apache-airflow[slack]" but this doesn't install SlackWebHookOperator as the import throws a “Cannot find reference slack_webhook_operator in init.py” error. Is there any other installation I am missing?
from airflow.contrib.operators.slack_webhook_operator import SlackWebHookOperator
I expect the SlackWebHookOperator to be able to be referenced.
I have tried installing slackclient dependency but it didn't installed SlackWebHookOperator as I cannot reference it.
SlackWebHookOperator is not available
For Airflow 2.x
airflow.contrib.operators.slack_webhook_operator has been deprecated.
You'd first have to install apache-airflow-providers-slack:
pip install apache-airflow-providers-slack
and finally import SlackWebhookOperator:
from airflow.providers.slack.operators.slack_webhook import SlackWebhookOperator
from airflow.providers.slack.operators.slack_webhook import SlackWebhookOperator
I am trying to use Watson Developer in my Jupyter Notebook, but for some reason I am getting error like this.
This is the import part:
import json
from watson_developer_cloud import AlchemyLanguageV1
After this I am getting error like this:
No module named 'watson_developer_cloud'
I installed Watson Developer cloud using command shell and ANACONDA prompt. This is the command which I used and it installed successfully.
pip install -I watson-developer-cloud==1.0.0
Do I need to configure any thing to avoid this error in my Jupyter Notebook while importing Watson Developer.
There are a few issues here.
1. The install you can use is:
pip install --upgrade watson-developer-cloud
The current version as of writing this answer is 2.0.1, not version 1.0
2. Alchemy no longer exists. You should be using NLU instead. There is sample code contained within the SDK.
from watson_developer_cloud import NaturalLanguageUnderstandingV1
from watson_developer_cloud.natural_language_understanding_v1 import Features, EntitiesOptions, KeywordsOptions
nlu = NaturalLanguageUnderstandingV1(
version='2017-02-27',
username='USERNAME',
password='PASSWORD')
features = Features(entities=EntitiesOptions(), keywords=KeywordsOptions())
response = nlu.analyze(language='en',
text='The goal is not to be perfect by the end, the goal is to be better today. - Simon Sinek',
features=features)
print(response)
You can view the SDK examples here: https://github.com/watson-developer-cloud/python-sdk/blob/master/examples
I am trying to use the requests module in a python script. I start by the import command and write the script however it is telling me that requests is not a module. Can anyone explain this to me? Is this not built in like "re" or do I have to import it in? I am new to python so any help would be great. Using Windows!
Thanks
Deirdre
No, requests is a 3rd party library. You can install it using pip.
pip install requests
And even if re is built-in, you have to import it in order to use it.