How to use this library in python "from digidevice import location"? - geolocation

How can I get coordinates from user's device, using this library in python: "from digidevice import location".
I tried, but cant even import this library.

This should help: link
It seems like this will work:
from digidevice import location
loc = location.Location()
print(loc.position)

Related

How to read google spreadsheet using google colab

We can list out spreadsheet present in google drive using below command
from google.colab import drive
drive.mount('/content/drive')
!ls -l /content/drive/'Shared drives'
but unable to read spreadsheet using below command
import gspread
from oauth2client.client import GoogleCredentials
gc = gspread.authorize(GoogleCredentials.get_application_default())
gc.open('/content/drive/'Shared drives/data.gsheet').data available
and also one more problem we have space in sheetname(data available) and we don't have access to change sheetname
I have refer link:: https://colab.research.google.com/notebooks/io.ipynb
Kindly help on it.
You can use gc.open_by_url('gsheets_url') to open the document (no need to mount the drive). For the sheet name, you can use gsheets.worksheet('sheet name').
So on your case it'd go something like:
from google.colab import auth
auth.authenticate_user()
import gspread
from oauth2client.client import GoogleCredentials
# setup
gc = gspread.authorize(GoogleCredentials.get_application_default())
# read data and put it in a dataframe
gsheets = gc.open_by_url('your-link')
sheets = gsheets.worksheet('data available').get_all_values()
df = pd.DataFrame(sheets[1:], columns=sheets[0])
(credits to this post)
Update to the answer by Murilo Cunha, as it gives errors for authentication
from google.colab import auth
auth.authenticate_user()
import gspread
from google.auth import default
creds, _ = default()
gc = gspread.authorize(creds)
import pandas as pd
# read data and put it in a dataframe
gsheets = gc.open_by_url('Your link')
sheets = gsheets.worksheet('data available').get_all_values()
df = pd.DataFrame(sheets[1:], columns=sheets[0])
It's helpful if you could say what is the exact error you get when you run this script. However, I notice there are redundant quotes in following script,
gc.open('/content/drive/'Shared drives/data.gsheet')
replace extra above by following,
gc.open('/content/drive/Shared drives/data.gsheet')
Another option is to try gc.open_by_url() instead of gc.open()

How to import custom modules in google colab? (Solution given here not working)

I'm trying to import a custom module called 'clusterer.py' into my colab notebook. But the import function is not able to find the file. Is there any other way to import custom modules?
After mounting the drive, I have already tried this approach: How to import custom modules in google colab? with the result: 'No module named 'clusterer''
!ls /content/gdrive/My\ Drive/Colab\ Notebooks/Omdena_Mars_Anomaly_Detection/*.py
!cat /content/gdrive/My\ Drive/Colab\ Notebooks/Omdena_Mars_Anomaly_Detection/clusterer.py
import sys
sys.path.append('/content/gdrive/My\ Drive/Colab\ Notebooks/Omdena_Mars_Anomaly_Detection')
import clusterer
The output is as follows:
'/content/gdrive/My Drive/Colab Notebooks/Omdena_Mars_Anomaly_Detection/clusterer.py'
'/content/gdrive/My Drive/Colab Notebooks/Omdena_Mars_Anomaly_Detection/feature_extractor.py'
[Contents of the module 'clusterer.py']
ModuleNotFoundError: No module named 'clusterer'
Ok, I think I figured out one solution. In my case, I had to physically go inside the directory where the files were. This is what I did
1a. Restart the kernel but 'resetting all runtimes', specially if you've just added your file.py to the directory.
1b.cd gdrive/My Drive/Colab Notebooks/Omdena_Mars_Anomaly_Detection
!ls /content/gdrive/My\ Drive/Colab\Notebooks/Omdena_Mars_Anomaly_Detection/*.py
!cat /content/gdrive/My\ Drive/Colab\ Notebooks/Omdena_Mars_Anomaly_Detection/mylib.py
import sys
sys.path.append('/content/gdrive/My\ Drive/Colab\ Notebooks/Omdena_Mars_Anomaly_Detection')
5.import clusterer
Worked for me.
Thanks

Forward package member in dart

I import a package and would forward a member of it. What syntax does Dart offer for that?
foo.dart
import 'package:xzy/xzy.dart'; // contains class Xyz
// how do I forward Xyz here to make it available in bar.dart?
bar.dart
import 'package:mypackage/foo.dart';
Xyz is hidden here
You can use export
import 'package:xzy/xzy.dart';
export 'package:xzy/xzy.dart' show Xyz;
or just
export 'package:xzy/xzy.dart' show Xyz;
You don't need to import for that. Just export is enough if you don't need Xyz in this re-exporting file.
See also
https://www.dartlang.org/guides/libraries/create-library-packages
What is the difference between "show" and "as" in an import statement?

connectWithResult method is undefined for MqttClient object

Below are my imports used in my java program. What I am trying to do is, to create a client of type MqttCient and then use the method connectWithResuls as follows
client.connectWithResult(opts);
the problem is eclipse underscores the lie mentioned above with red squiggle, and I do not know why, I also referred to Paho java docs here.
please let me know why the aforementioned method is not recognised.
Imports
import org.eclipse.paho.client.mqttv3.IMqttActionListener;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.IMqttToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.MqttPersistenceException;

how to create exe of Python Code using opencv with or without py2exe?

i have some Python Code working properly its some kinda simple thing using opencv.
for example
import cv2
x = cv2.imread('Dog6.jpg')
cv2.imwrite('new2.jpg')
setup.py is
from distutils.core import setup
import py2exe
import cv2
setup(console=['name.py'])
but i am unable to create exe of this code with py2exe.
is there another method to create exe of such program ?
Error is
ImportError:numpy.core.multiarray failed to import
Put the line:
import numpy
Into your script, i.e the first file and try again.

Resources