I am trying out this new python package ib_insync.
https://github.com/erdewit/ib_insync
I ran the python script below;
from ib_insync import *
ib = IB()
ib.connect('127.0.0.1', 7496, clientId=1)
contract = Forex('EURUSD')
bars = ib.reqHistoricalData(contract, endDateTime='', durationStr='30 D', barSizeSetting='1 hour', whatToShow='MIDPOINT', useRTH=True)
# convert to pandas dataframe:
df = util.df(bars)
print(df[['date', 'open', 'high', 'low', 'close']])
I encountered the error IB API from http://interactivebrokers.github.io is required.
I have already installed IB API ver 9.73.06 under C:\TW_API folder. I am using Windows 10 and anaconda python v3.6 .
Here is a snapshot of my TWS API settings;
I found the answer to my own question. The problem was that ib-api python module was not installed into the python version that I am using
There is a README.md found in C:\TW_API\source\pythonclient
Following the instructions, I ran the following commands;
$ python setup.py bdist_wheel
$ python -m pip install --user --upgrade dist/ibapi-9.73.6-py3-none-any.whl
My python script runs normally without error now.
After installing the TWS API, locate the folder "TWS API". In that folder, find the folder named "source", then the folder named "pythonclient".
Once you're in the folder "pythonclient", copy all the content in there and paste it into your working directory.
You should no longer get the IB API from http://interactivebrokers.github.io is required error again.
This is a general error that occurs when the Python interpreter can't find a module because its not listed in the PYTHONPATH environment variable. One option is to install the ibapi module as a Wheel. Or, if you are using an IDE such as PyCharm you can just right-click on the pythonclient folder in the project directory in the IDE and choose "Mark Directory as Source". This is mentioned in the recorded IBKR Python API webinar.
Since a Python API program is dependent on a specific version of the API, many users also like to use virtual environments (virtualenv) to organize version-specific dependencies of code rather than installing everything globally.
For windows 10:
Maybe as of Feb 2022 none of the above-mentioned options works. Please, try the following:
import sys
sys.path.append("C:\\TWS_API\\source\\pythonclient")
import ibapi
The TWS API is installed in this folder: c:\TWS_API
Related
I want to connect to firebase on replit using python. I'm using the code below:
from firebase import firebase
firebase = firebase.FirebaseApplication("my firebase url", None)
data = {
'ddfjaklfbja': 'dklabja;kdlf',
'adfjlkgadjf': 'dkaljbaowq',
'afbiouadofpia': 'dsajklbjanzm'
}
result = firebase.post('/test1', data)
print(result)
However, when I try to run it, it returns an error saying that there is no module named urllib3:
ModuleNotFoundError: No module named 'urllib3'
When I try to use the packages tab to install it on the left, it does not install and returns with the same error (there are multiple lines but the last line says this). How can I fix it?
Their are multiple things you can try:
Open your command prompt and enter "pip install urllib3"
If it can't install it try this: python3 -m pip install urllib3 or pip3 install urllib3
Perhaps it helps when you add this to your python file: import urllib3
this issue is related to Python path, and with the python interpreter. Make sure you are using the python interpreter in which you have installed the modules. (If using 3.9 use python 3.9 as interpreter as opposed to 3.10). If this doesnt work check python path. Other easy solution is to change your project folder to one that imported your modules correctly.
I try the example on: https://github.com/Azure-Samples/ms-identity-python-webapp with Windows 10, but I get an error with ModuleNotFoundError: No module named 'flask_caching.backends.filesystem' (Flask-Caching is already installed with pip).
Version:
Python 3.9.9,
Flask 1.1.4 and
Werkzeug 1.0.1.
I only changed the code with Client_ID, CLient_Secret and domain name in app_config.py.
Has anybody an idea?
The error ModuleNotFoundError means python interpreter cannot find the libraries which you are referring to in the code although the module is already installed.
Common causes of this error:
Using modules meant for different python versions but Installing python 2.x modules in python 3.x and vice a versa.
When not properly setting PATH variable.
(Or)
If you are using a python virtual environment. It need to be installed after creating a virtual environment as commented by #grumpyp . The libraries will reside inside the folder created for the virtual environment.
And can installed according to requirements.txt file
pip install virtualenv
It requires activation and dedicated installation of modules inside the virtual environment.
Refer this blog for more details to do
pip install -r requirements.txt
Other reference :Set Up a Virtual Python Environment (Windows)
(or )
This may not be your query but Just to make it a bit easy You can try this way when trying out your sample project to compare with manually configured one.
The quick start: "Add sign-in with Microsoft to a Python web app" that you are using ,can be directly configured in portal quickstart like below where every thing is configured including client id ,tenant id etc directly.
Just register the app with name and account type and follow the steps below for direct configuration .
Go to quickstart page of app
Select Python as platform for web application
Just follow the steps to configure azure ad inside app directly
There after following the steps , I checked the versions with pip freeze and
versions i have: Python 3.9.7, Flask 1.1.4 and Werkzeug 1.0.1.
quickstart-v2-python-webapp | microsoftdocs
Introduction
I've uploaded a python package up to a local PyPI inside Artifactory. I've installed it on my system with pip install foo (I need to authenticate). I can do python -c "import foo" without any issue.
When I try to make use of this module inside PyCharm (with import foo), PyCharm throws me unresolved reference 'foo'.
So I went into Preferences->Project:myproject->Project Interpreter->Available Packages->Manage Repositories and added the local PyPI as shown below:
but when reloading the package list in the 'Available Packages' I get the following error dialog:
401 forbidden makes since since I was never prompted for credentials, but I'm not sure how to proceed.
Question
How can I import package foo inside a PyCharm project?
PyCharm doesn't support authentication for custom package repositories, please vote for the corresponding ticket in the IDE's bug tracker https://youtrack.jetbrains.com/issue/PY-26556
Meanwhile, you should be fine installing the package from the terminal on the interpreter used as a project interpreter in PyCharm (Settings | Project ... | Project Interpreter).
Update to this. With version 2021.1, it looks like if you set the PIP_INDEX_URL environment variable to your Artifactory repo containing your credentials (username and API Key), you can use the "View -> Tool Window -> Python Packages" tool to install packages from your Artifactory PyPi repo. So, you would do something like:
PIP_INDEX_URL=https://<Artifactory Username>:<Artifactory API Key>#mycompany.jfrog.io/mycompany/api/pypi/pypi-org-remote/simple
Or whatever the URL is to your Artifactory pypi repo. For whatever reason, you can install from the "Python Packages" tool window, but you cannot use the "Setting -> Projects -> Python Interpreter" to install packages.
Alright, have been installing Google Assistant on my Windows 10 PC and have been met with multiple errors, the last of which I solved by going here: Google Assistant Installation on Python3.6 OSX
Now, I have everything installed, and want to test my mic and then start using the assistant. However, when I put in the commands
python -m googlesamples.assistant.audio_helpers
and
python -m googlesamples.assistant
I get this error:
C:\Users\robmak3>python -m googlesamples.assistant
C:\Users\robmak3\AppData\Local\Programs\Python\Python36\python.exe: No
module named googlesamples.assistant.__main__; 'googlesamples.assistant' is
a package and cannot be directly executed
I've been trying to follow this guide: https://www.xda-developers.com/how-to-get-google-assistant-on-your-windows-mac-or-linux-machine/
Any help fixing this would be great! Thanks!
As per version 0.3.0 of the SDK the gRPC samples are using a different auth helpers.
pip install --upgrade google-auth-oauthlib[tool]
google-oauthlib-tool --client-secrets path/to/client_secret_XXXXX.json --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless
And you can launch the update gRPC sample with:
python -m googlesamples.assistant.grpc.pushtotalk
You should be able to follow the instructions from the SDK package and gRPC package page and explore the reference sample
Try this command instead:
python -m googlesamples.assistant.grpc.audio_helpers
If you go to the following path you will notice that there is a directory named grpc inside assistant directory.
C:\Users\%username%\appdata\local\programs\python\python36-32\lib\site-packages\googlesamples\assistant\
That is why you need to append .grpc next to assistant. And inside grpc directory you can see audio_helpers.py script.
To launch google assistant enter following command:
python -m googlesamples.assistant.grpc.pushtotalk
This should be pretty basic as I've installed lots of python packages, but I can't for the life of my get google apis client library for python to install.
I'm pressure sure I've gone through the instructions on this website properly:
https://developers.google.com/api-client-library/python/start/installation
To summarize I've done the following:
$ easy_install --upgrade google-api-python-client
this seems to work fine, doesn't report any errors or warnings
downloaded and unzipped google-api-python-client-gae-1.2.zip into the directory where my project is
but if I open an iPython session in the folder where I unpacked the full dependencies I can't do the basic imports such as:
import google.appengine.api it just says "No Module named google.appengine.api"
I checked in my site-packages folder and google_api_python_client-1.2-py2.7.egg is there. But it doesn't show up in sys.path
when I do sys.path.append('C:\Anaconda\Lib\site-packages\google_api_python_cli
ent-1.2-py2.7.egg') it adds the correct path, but the import still doesn't work.
EDIT: This fixed my problem
Adding the Google SDK to my Python path did the trick. I don't know why the installer didn't do this when I ran it. but hey, this worked
So if I run:
sys.path.append('C:\\Program Files (x86)\\Google\\google_appengine')
from google.appengine import api
works!
Without knowing all the steps you took to install app engine and the client APIs, my only recommendation is to install (or reinstall) the Google App Engine Python SDK from here: https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Python. Looks like you're on windows, so you would grab the MSI.
Just make sure you launch the AppEngineLauncher application after installation as it will give you the option to create symlinks so you can run commands from terminal.