Fetch Google Places Data using Python - google-api

I'm trying to write a short python script which fetches data from Google Places API and exports it as a .csv file.
Unfortunately I'm stuck right at the beginning.
I want to use requests package but my machine cannot find it.
I've installed Python 3.5 on my Mac and when I use pip to install requests it says:
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
But when I run the program I get an import error which says:
ImportError: No module named requests
Do you have any ideas how i can fix this issue?
Thanks in advance.
Much love.

Use python -m pip install requests instead. Your pip installation was probably for a different version.

Related

How to install solaris (on colab or locally)?

I try since multiple days to install solaris (https://github.com/CosmiQ/solaris) locally, on google colab or on renkulab (https://renkulab.io/). Up to now, without any luck. I tried on all platform different approaches:
Creating a conda environment (as recommended by the authors)
Directly through pip
And also cloning the repository and access the folders and functions directly
All of these approaches failed so far. Mostly there is a wheel building error for GDAL. Which i have installed first. I do not find any proper documentation or other failure descriptions which makes me question myself... Maybe here someone has experience with this library?
I highly appreciate every hint.
Thanks a lot
Colab Setup
I can get it set up in Colab with the following:
First Cell: Install Mamba/Conda
!pip install -q condacolab
import condacolab
condacolab.install()
This will trigger a runtime restart - it does this on purpose.
Second Cell: Install Solaris prerequisites
I'm assuming we want the GPU-enabled version. If not, there is another YAML in the solaris repository for a CPU-only environment.
!wget https://raw.githubusercontent.com/CosmiQ/solaris/main/environment-gpu.yml
!mamba env update -n base -f environment-gpu.yml
Manually restart the runtime after this completes!
Third Cell: Install Solaris
!pip install solaris
That should be it. Following these steps, I could import the module and use the entrypoints, e.g.,
Module import ✅
import solaris
Example entrypoint ✅
!make_masks -h
There were some future deprecation warnings from NumPy about some syntax in the TensorFlow code, but otherwise, seems functional. However, I don't personally use this tool, so I don't know if there is more to verify.

flair import failing on mac ubuntu and google colab

i am trying to use flair nlp framework ,
https://github.com/flairNLP/flair
but getting error
# load the NER tagger
tagger = SequenceTagger.load('ner')
tried on local , remote and other machine . all failing as its not able to download a model from s3 .google colab also gives same error .
all give error message as:
OSError: HEAD request failed for url https://s3.eu-central-1.amazonaws.com/alan-nlp/resources/models-v0.4/NER-conll03-english/en-ner-conll03-v0.4.pt with status code 301.
.
I was having the same issue, I don't know what happen with the link but I found another one.
You can look flair master repo https://github.com/flairNLP/flair/blob/master/flair/models/sequence_tagger_model.py
on the def _fetch_model(model_name) line 971.
There are using another path already "https://nlp.informatik.hu-berlin.de/resources/models", so they change to that path instead of alan-nlp.
So you can find your model here https://nlp.informatik.hu-berlin.de/resources/models/ner/
I had a similar problem to this.
Note that flair now hosts the majority of their models on Huggingface.
Most likely what you need to do is install the latest version of flair which has the sequence_tagger_model.py (and probably others) pointing to the right link.
I had to uninstall flair, and then reinstall it:
pip uninstall flair
pip install flair
to ensure it worked.

No matching distribution found for time Heroku

I was trying to deploy a python script to Heroku that uses the time module in Python. I put the time module in requirements.txt and Heroku tries to collect it but I get this error:
No matching distribution found for time
Why is this happening, and how can I fix it?
I put the time module in requirements.txt
Don't do that.
time is part of Python's standard library; it comes with Python and is available automatically.
requirements.txt is only for third-party modules. Remove time from your requirements.txt, commit, and redeploy.
Time is a module that is already included with python. This is why you cannot install the module "time" using pip. So if you do not include it in the requirements.txt it will work fine. As Heroku has the python version thus also the time module you need.
Make sure to read the documentation of python: https://docs.python.org/3/library/time.html

how can I manually install a module in qpython?

I am using qpython as a non-root user and I have googled it up but all recommendations don't work both manually and using pip...I keep on getting errors...
I get erors when I use both:
pip install requests from pip console
and:
import pip
pip.main(['install','requests']) on python console
The error is something like:
cannot fetch base url https://pypi.python.org/simple/
could not find any downloads that satisfy the condition requests
...
if there is a workaround or a fix I would be happy to accept...
Did you use the newest version(>=2.0.7) Installing requests from QPYPI works well in the newest version. https://github.com/qpython-android/qpython/releases
Yes! This fixed my problem once I used the beta v2.1 from
https://github.com/qpython-android/qpython/releases
Google play did not give me the latest version (I had 1.xx)
I was able to use QPYPY to install requests and it automatically installed the required library urllib3.

jython 2.7 package installation

Jython Package installation issue, using pip
Hi, I have installed Jython2.7 configured with pydev in eclipse neon, also configured python 3.6 package
I am able to install packages for python using pip installer?
pip install "packagename"
Below are some of the packages in python/Lib/Site-packages directory
I was able to install all the packages
How do I use pip installer to install packages for jython?
I tried to install Jip package with
jython install setup.py
The binary File got installed in the Jython/Lib/Site-packages folder
However, I am not able to use it.
where and how do I get Jython package binaries like jip?
Also, Please let me know how to search jython packages?
Also, How to make pip install library packages in jython?
Any other configuration like jython home, etc that should be made?
This answer is going to be really generic but I just recently have slogged my way through the setup for jython/jip/pip and here's roughly what I had to do.
Firstly, I'm running Windows 7 64 Bit from behind a proxy (work machine.)
Had to install jython 2.7.0 instead of 2.7.1 because (I think anyway) 2.7.1 requires admin privileges which I don't have on my work PC.
Pip didn't install correctly during the Jython installation and I spent an obscene amount of time trying to get it installed and functioning as I knew it from my cpython days. NOTE: Just because you get pip installed, doesn't mean you can use any package on a python package repo. As of 2.7.0, Jython doesn't have end to end capability to interpret/compile some libraries that rely on certain python wrappers of native OS function calls. I believe 2.7.1 makes solid progress in the direction of supporting all needed native calls but don't quote me on that. For example, I tried to use wxPython to make a simple GUI to test my jython install. Trying to install it from pip kept causing really non-specific error info that took me a lot of time to figure out that the cause was jython simply couldn't compile the wxPython source so beware.
I had to set environment variables 'http_proxy' and 'https_proxy' in the form of http://proxyhosturl:port and https://proxyhosturl:port respectively to get out from behind the proxies without having to invoke pip with the proxy switch every time I called it.
To actually install pip, have a look here. These instructions are for Python and Linux/Unix but the principle is roughly the same. Just use jython -m instead of python -m and ignore the '$' at the start of each command line.
Also be sure to CD to your python_home/bin folder when invoking the ez_install exe.
If that doesn't work (didn't for me), try using get-pip.py script with these instructions https://pip.pypa.io/en/stable/installing/ (remember jython instead of python etc.). Download it, cd to the download location and follow the noted install steps. Worth noting is about half way down the install instructions where it details installing from local archives (source/binary zip or tar.gz archives of pip and setuptools as better described here: https://packaging.python.org/tutorials/installing-packages/#installing-from-local-archives).
The links to the bin archives of pip and setuptools are here:
https://pypi.python.org/pypi/setuptools
https://pypi.python.org/pypi/pip
It may also be worth making sure that your PATH environment variable has the jython/bin path in the variable value. The jython installer should do this but, again, mine did not.
If all goes well, you should be able to invoke pip with the --version switch and if it prints a line with the installed pip version info then you should be good to go
Another quirky issue I had was I could invoke a function of pip one time and any subsequent times I would get a stack trace ending with something along the lines of an object not having a certain property. I fixed that by finding my temp directory by opening a windows explorer instance and typing %TEMP% in the address bar and hitting enter, it should take you to a subdir of your AppData folder and there you may see a folder with the name of the package you were trying to install and the text "_pip" somewhere in the directory name. Delete the directory and try the pip install command again. I had to do this + invoke pip install pip -U to update my install to the latest version. Then pip began behaving correctly in my instance.
pip search numpy (or your library name) will generate a list of results with the same logic it uses to locate your desired package when you call pip install but, again, just because it returns a matching package doesn't mean it will compile when you install it (numpy doesn't work because of the missing java to C native function calls I described earlier.) The trade off is that you can import code artifacts from Java JAR files in your Jython script files and leverage their functionality with relative ease. Between the public Java APIs available and the python packages that work with the jython interpretor, you can (in my experience) come up with a way to accomplish your task. See the following info on JIP, Maven and IDEs.
IDE and jython integration (Eclipse)
- If you are stuck using Eclipse (like me) it actually has pretty decent support for python development. Install the PyDev plugin for Eclipse from Help -> Install Software. Put in this URL https://marketplace.eclipse.org/content/pydev-python-ide-eclipse, hit tab, and select the PyDev plugin and hit 'finish.'
- Setup the jython interpretor info from Windows -> Preferences -> PyDev. Provide the path to your jython.jar file.
- You should now be able to use File -> New PyDev project to create a basic python project and configure it to use your version of Jython and Java.
Brief Overview of Jip and Maven
- jip is a jython package that is invoked very similarly to pip but instead will download JAR files from the Maven Central Repository instead of python packages from pypi.com, for example. See the install instructions described here. Note the install procedure for a global jip install which differ from just pip install jip. https://pypi.python.org/pypi/jip/
- I never got jip to work exactly as I wished because there's not a ton of documentation on it outside of what I already linked. However, if you install a JAR using jip, you have to go to your project in Eclipse and actually add the JARs themselves to your PYTHONPATH in order for import statements and editing to have intellisense and so that you don't get a classnotfound exception at runtime. See following screen shot.
- There is a JIP config file that you can use similar to the pip config ini file but I have yet to find any exhaustive documentation on it's setup.
Note in the above screen shot the first entry in the External libraries entries. By default, pip places installed packages in that directory so to enable eclipse to find them, you need to also ensure that location is entered.
In Conclusion
- I have more to add to this answer and I will do so as soon as possible. In the meantime, see this example project I've loaded into github.
https://github.com/jheidlage1222/jython_java_integration_example
It shows basic config and how to interface with JARs from python code. I used the apache httpcomponents library as an example. Good luck amigo.

Resources