connecting python to Bloomberg - python

i am trying to connect my pycharm to my Bloomberg terminal. At my old company the infrastrcutre was already setup but not at this smaller company. I am using the link provided by bloomberg (https://www.bloomberg.com/professional/support/api-library/) but because of the security setup on my work pc I cannot pip install this (>> python -m pip install --index-url=https://bcms.bloomberg.com/pip/simple blpapi). Does anyone know how to
connect to bloomberg using baby steps
manually download these packages instead of pip install
where to save these packages to import them into the code
Thanks

Are you allowed to use virtualenv?
If you are you can just do:
virtualenv env
source env/bin/activate
pip install --index-url=https://bcms.bloomberg.com/pip/simple blpapi
That will then install it only to your local virtual environment.
If you're not, you also just open https://bcms.bloomberg.com/pip/simple/blpapi/ and download the libraries yourself, uncompress them, and put the files on the PYTHONPATH of your application.

I was interested in the question so thought I'd share what I found poking around.
Edit: Grab the wheel file from the site https://bcms.bloomberg.com/pip/simple/blpapi/ and try these ideas with help from this question: Install python wheel file without using pip
(Edit: the link was down when I looked, now it is up so grab the right one for your platform.)
Pycharm has a lot of tools to install things in a virtual env, if they block that at work, but let you install pycharm and python then things are a little messed up. Just sayin...
If you get into pycharm settings and go to project interpreter and then click add you can search bloomberg and there are 3 projects. You might see if those have any support. They do have email addresses you can contact the people. Those might be old and no good anymore or they might be better, who knows.
Hopefully these ideas give you a new lead somewhere.

Related

PyCharm cannot install packages

Short description: two computers in the same network, in the new one only those python scripts work that use native packages.
I have Pycharm in my old computer and it has worked fine. Now I got a new computer, installed the most recent version of Python and Pycharm, then opened one of my old projects. Both the old and the new computer are in the same network and the project is on a shared folder. So I did the following:
File - Open - selected the project. Got a message that there is no interpreter
Add local interpreter - selected the latest Python 311 exe. So location of the venv is the same as in the old computer (because it's a network folder) but Base interpreter is pointing to the C drive of my new computer.
PyCharm creates a virtual environment and the code runs fine.
I select another project which uses imported packages such as pandas. Again, same steps as above, add local interpreter. Venv is created.
I go to File - Setting - Project and see that pip, setuptools and wheel are listed as Packages. If I double click one of these, I can re-install and get a note that installation is succesful, so nothing seems to be wrong in the connection (after all, both the old and the new computer are in the same network.
I click the plus sign to add a new one, search pandas. Installation fails. Same thing if I try e.g. numpy.
Error message has lots of retrying, then "could not find the version that satisfies the requirement pandas (from versions: none", "not matching distribution found for pandas" (pip etc. have the latest versions).
After few hours of googling for solutions, I have tried the following:
Complety uninstall and reinstall python and PyCharm. Checked that PATH was included in the installation.
Tried launching pip command from shell
Changed http proxy to auto-detect
Typed 'import pandas' in PyCharm, then used the dropdown in the yellow bulb but there is no install option
Started a new project in the new computer, tried to install pandas
All failed. I'm surprised that changing computers is this difficult. Please let me know if there are other options than staying in the old computer...
If you want to use venv in the network, please use SSH interpreter. Pycharm supports this method. Shared folders are not a recommended usage, For pycharm, it will consider this as a local file. If the file map is not downloaded locally, it will make an error.
Another way is to reinstall the project environment on the new computer through requirement.txt. Reasonable use of requirements.txt can effectively avoid many project bugs caused by environment migration or different dependent versions. Before installing some scientific module such as pandas, it is recommended to install visual studio build tools, such as gcc ...
This took a while but here is what happened. Package installation did not work in project settings. Neither did it work when you select Python Packages tab at the bottom of the screen. The only thing that worked was to select the Terminal tab and manually install (pip install) there. We use a trusted repository but for other users, the easier package installation methods work. Not sure why they do not for me but at least there is this manual workaround.

Run a Python script on a host without Internet connection

I read all the proposed related questions but didn't find an answer to my case.
As for the title, I need to run a Python script (e.i. not an executable created with pyInstall) on a Windows VM that is not connected to the Internet. I can only download packages via browser.
Install Python is not a problem, but pip doesn't work, so I have the libraries issue.
Do you have any suggestions?
If you go to PyPi, where pip searches for packages, and find a package you are interested in, you can click on "Download Files" on the left panel. Using numpy as an example: https://pypi.org/project/numpy/#files
You can manually download the files that you want for each package and install them directly with pip. Keep in mind that the first couple of rounds will likely involve error messages telling you that there are missing dependencies. You will have to go back to PyPi and get those dependencies as well, until everything installs correctly.
You may want to check the following question for information regarding manual dependency management: How to extract dependencies from a PyPi package.

Do others need to have the same modules installed to run my code in Python?

If I use a module such as tkinter, would somebody need to have that module installed as well in order for my code to run on their machine?
Definitely. You can use virtual environments or containers to deliver required packages or have a requrements.txt or similar to install the dependencies.
python comes with a number of standard modules pre-installed, if the other person is running python (the same version of you) then he/she won't need to install anything, it will just work, that's the case of tkinter. But if you use external packages that you installed to run your code, for example celery, then he/she will need to do the same thing.
If you gave your code to someone to run, they would need to download the same modules, unless you also sent the environment too. The only way I know around this is to freeze your code where you would create an executable. I've used cx_Freeze and pyInstaller and haven't had any issues but it also depends on your needs. You can find some more information through here:
https://docs.python-guide.org/shipping/freezing/
Hope this helps!
In your running environment do a, this file you add to your repo
pip freeze > requirements.txt
When people clone your repo, they only have to do a:
pip install -r requirements.txt
and they will install exactly the same pypi modules you have.
With virtualenv you can isolate a python environment to each project, with pyenv you can use different pythonversions withing the various environment also.

Unable to install packages -- Pycharm -- Python.exec path not working

I am trying to install packages to use in a python program and am unable to install anything. Included below are screen shots showing the interpreter selected, the path of that interpreter, and the error message I receive. Please let me know what I am missing.
I've been looking around at other people's problems like this and nothing seems to fit my issue.
This kind of error seems like you do not have a stable connection to the pypi. The standard recommendation would be to "Make sure you are connected to the internet, Pycharm is allowed through the firewall and that your proxy (if you are behind one) allows access to this url address."
Now that is not very helpful so if this issue is happening over a single package, you can simply download the python wheel from the beautifulsoup's project page and install it manually by running pip install downloaded_whl_file.whl in the Pycharm's terminal (make sure that the environment is right!)
Lastly, you might be able to get around it by using a pip proxy through pip install beautifulsoup4 --proxy http://some-proxy.com
I hope that the above can help you get through your issue!

Can't find a way to install gettext from PIP virtualenv

Overall I'm trying to use a module in Django that helps with translating pages, but I don't have installed and can't do it through pip install package.
I've tried the fllowing:
pip install gettext
That returns that could not find a version that requires the...
I also downloaded the tar.gz file from the official website, yet when I try to install it localy the error:
python setup.py egg_info failed with error code 1 windows
Comes up. Been reading, trying to fix the second error or possible solutions, installed ez_update, updatade all packages, made a rollback and I don't know what to do anymore, any help?
The package gettext is available as python-gettext in Python pypi
Please use
pip install python-gettext
I was struggling with the same issue and what worked for me eventually is the following:
download gettext-runtime-0.17.zip and gettext-tools-0.17.zip (or the latest version) from here:
http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
Place both directories in your project directory (say myProject)
Now, in each of these folders there is a bin folder. Go into it and copy the address. Each would look sth like:
C:\myProject\gettext-runtime-0.17\bin
C:\myProject\gettext-tools-0.17\bin
Go into: control panel > System > Advanced System settings > Environment variables. In system variables, choose Path and click
'edit'.
Paste both addresses at the end, like this:
;C:\myProject\gettext-runtime-0.17\bin;C:\myProject\gettext-tools-0.17\bin
(don't forget the semicolon after the last existing item)
Activate your virtualenv and run the makemessages command. It should work.

Categories