google-colaboratory

How to force google colab to run in particular python version

Deadly 提交于 2021-01-29 09:48:59
问题 I have a code which works in python3.5 but will throw errors in python>3.5 but with !python --version in google colab return python 3.6.9, is there any way I can force google colab to use 3.5. I found some solutions in Stackoverflow which asked me to use local run time which won't be useful for me because I don't have enough computational resources in my local machine. 来源: https://stackoverflow.com/questions/59788607/how-to-force-google-colab-to-run-in-particular-python-version

IPython magic-command %notebook does not work when spaces are present in path (Google Colab)

前提是你 提交于 2021-01-29 08:51:05
问题 In jupyter-lab I can use the magic command %notebook $output_file_path to save the history notebook as a jupyter notebook. When I am working with Google Colab (mounting Google Drive) the path of my notebook folder is something like: root_path = 'gdrive/My Drive/Colab Notebooks/my_working_folder/' The problem is that, as I try to save the notebook history, the space between "My" and "Drive" makes the magic command fail output_file_path = 'gdrive/My Drive/Colab Notebooks/my_working_folder/nb

pd.Series.to_list() changing dtype

孤街浪徒 提交于 2021-01-29 02:25:30
问题 When I am programming on colab, I keep running into this issue: Here is my df: 0 1 0 [2.7436598593417045e-05, 3.731542193080655e-05] 1 [8.279973504084787e-05, 2.145002145002145e-05] 2 [0.00022534319714215346, 0.0002031172259231674] 3 [3.239841667031943e-05, 2.7771297808289177e-05] 4 [0.00011311134356928321, 9.428422928088026e-05] I want to get the data from df[1] into a list of lists so I can feed it into my model. To do so, I run: df[1].to_list() and i get: ['[2.7436598593417045e-05, 3

import pyzbar.pyzbar - Unable to find zbar shared library

廉价感情. 提交于 2021-01-28 22:44:47
问题 I want to make a script for detecting and reading QR codes from photos. I would like to use PyZbar for that, but I have a problem with some errors. I'm working in google colaboratory !sudo apt install tesseract-ocr !pip install pytesseract !pip install pyzbar[scripts] import shutil import os import random import re import cv2 import numpy as np import pytesseract from pytesseract import Output %matplotlib inline import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.pylab

googletrans Translate() not working on Spyder but works on Colab

别等时光非礼了梦想. 提交于 2021-01-28 21:32:06
问题 I am using googletrans Translator on offline data in local repo: translator = Translator() translations = [] for element in df['myText']: translations.append(translator.translate(element).text) df['translations'] = translations On Google Colab it works fine(20 mins) but on my machine it takes 30 mins and stops with ReadTimeout error: File "<ipython-input-9-2209313a9a78>", line 4, in <module> translations.append(translator.translate(element).text) File "C:\Anaconda3\lib\site-packages

Resource localhost/total/N10tensorflow3VarE does not exist

六眼飞鱼酱① 提交于 2021-01-28 20:11:43
问题 I'm working with Google Colab and trying to train a model using VGG blocks. Like this: METRICS = [ keras.metrics.TruePositives(name='tp'), keras.metrics.FalsePositives(name='fp'), keras.metrics.TrueNegatives(name='tn'), keras.metrics.FalseNegatives(name='fn'), keras.metrics.BinaryAccuracy(name='accuracy'), keras.metrics.Precision(name='precision'), keras.metrics.Recall(name='recall'), keras.metrics.AUC(name='auc'), ] # function for creating a vgg block def vgg_block(layer_in, n_filters, n

Loading font from URL to Pillow

天大地大妈咪最大 提交于 2021-01-28 18:57:37
问题 Is there a way to load a font with Pillow library directly from url, preferably into Google Colab? I tried something like from PIL import Image, ImageDraw, ImageFont ImageFont.truetype("https://github.com/googlefonts/roboto/blob/master/src/hinted/Roboto-Regular.ttf?raw=true", 15) Yet I get an error of OSError: cannot open resource . I tried with Google Fonts too, but to no avail. 回答1: Try it like this: import requests from io import BytesIO req = requests.get("https://github.com/googlefonts

Insert Image in Google Colab Text Cell

冷暖自知 提交于 2021-01-28 05:45:55
问题 I want to insert an image to a text cell in google colab which I have already uploaded in google drive. For this I use markdown syntax: ![Name]("Get shareable link") But it doesn't work. My link looks like this: https://drive.google.com/file/d/16teg5zUQhl01IOgvnP61aFjj0kFrviwr/view?usp=sharing and not like this https://docs.google.com/uc?id=---- Does anyone know where the problem is? Thank you very much! 回答1: You can change to direct URL format ![](https://drive.google.com/uc?id

Installing CERN ROOT on google Jupyter Notebook

淺唱寂寞╮ 提交于 2021-01-28 02:53:58
问题 I have tried to install CERN ROOT http://root.cern.ch on google colaboratory Jupiter notebook https://colab.research.google.com. I can't get python running with ROOT, it crashes at: import ROOT I have been installing ROOT as usual: !mkdir -p APPS !pwd !cd APPS && wget https://root.cern/download/root_v6.16.00.Linux-ubuntu18-x86_64-gcc7.3.tar.gz !cd APPS && tar -xf root_v6.16.00.Linux-ubuntu18-x86_64-gcc7.3.tar.gz !ls APPS/root/bin/thisroot.sh !source APPS/root/bin/thisroot.sh !echo $ROOTSYS

Different timezone in Google Colab

核能气质少年 提交于 2021-01-28 02:08:14
问题 Question: Why does the timezone in Colab different from local timezone? Background: : I'm living in US. But the there is a five hours difference between the Colab time (I specify the US timezone) and local time. Code: !rm /etc/localtime !ln -s /usr/share/zoneinfo/US /etc/localtime # the time should be around 11:20 !date Results: Wed Aug 7 16:20:40 UTC 2019 回答1: You can change the timezone in two steps: Step 1: Find the name of your timezone in the hierarchy !ls -al /usr/share/zoneinfo/ For US