Running python commands in a terminal in Google Colab - google-colaboratory

I've uploaded a directory of codes in Google Colabs. I need to run python command lines in a terminal that I'm unable to open.
I tried each and every solution suggested in How can I run shell (terminal) in Google Colab? but to no avail.

Updated 20220202
Can you try to execute your python scripts using the exclamation mark ! from Colab's cell directly?
I believe I encountered identical issue back in my Colab days, the process will hung or froze over some time, especially when I am dealing with GBs of datasets. So, ultimately I just ran using the exclamation mark directly from my Colab's cell to resolve the issue.
Have you tried this with the following syntax?
!pip install google-colab-shell
from google_colab_shell import getshell
getshell()
getshell(height=400)
I understood that you have tried the solution from another post, but just in case that you missed out the !, and ignored the warning message, and that exclamation mark was actually causing the shell not spawning.

Related

Colab: Cannot run any cell after changing the runtime to local

I'm new to Tensorflow and I just started using Google Colab a week ago, and I want to run it locally so that it can use my own CPU to avoid Colab Resource Restrictions, so I followed the Official guide on running Colab locally, and after I'm all set and try to run any cell in the Colab, it pops up this error:
And then immediately changed to this -
And here is the full runtime logs it gave me:
Could not fetch resource at : 404 Not Found
FetchError: Could not fetch resource at : 404 Not Found
at ny.fr [as constructor] (https://colab.research.google.com/v2/external/external_polymer_binary.js?vrz=colab-20210513-060327-RC00_373550014:684:397)
at new ny (https://colab.research.google.com/v2/external/external_polymer_binary.js?vrz=colab-20210513-060327-RC00_373550014:1299:1093)
at za.program_ (https://colab.research.google.com/v2/external/external_polymer_binary.js?vrz=colab-20210513-060327-RC00_373550014:5067:158)
at Ba (https://colab.research.google.com/v2/external/external_polymer_binary.js?vrz=colab-20210513-060327-RC00_373550014:19:336)
at za.next_ (https://colab.research.google.com/v2/external/external_polymer_binary.js?vrz=colab-20210513-060327-RC00_373550014:17:503)
at Ca.next (https://colab.research.google.com/v2/external/external_polymer_binary.js?vrz=colab-20210513-060327-RC00_373550014:20:206)
at f (https://colab.research.google.com/v2/external/external_polymer_binary.js?vrz=colab-20210513-060327-RC00_373550014:61:101)
Since I've been struggling with this error all day, and I also reinstall and upgrade the Python, TensorFlow as well as the jupyter-notebook a few times, so PLEASE HELP ME!!! Or if anyone knows how to change the runtime back to browser will also be helpful, I'm kind of stuck here...
Since you mentioned you are new to colab, just double checking the basics - did you try Connect Button (in top right area of colab) and choosing "Connect to Local Run time"?
Also note that sometimes large datasets cause out of memory error, so that might be one cause too.

Install Tensorflow Object Detection API - 'cp' error

I'm trying to install the Tensorflow Object Detection API, following several tutorials and the official documentation (Tensorflow Object Detection API). I've encountered multiple times the same error when running through the command prompt the following command:
>cp object detection/packages/tf2/setup.py .
'cp' is not recognized as an internal or external command, operable program or batch file.
Any help would be appreciated. I've also tried using "copy" instead of "cp" but no result.
P.S. I've installed GPU support as well.
You can use:
copy object_detection\\packages\\tf2\\setup.py .
With double back slashes. This works for me in -cmd editor
cp won't work on command prompt. Try running it on powershell as
cp '.\object detection\packages\tf2\setup.py' .
I faced the same issue but I went through these answers and figured it out thank you and I used PowerShell with minor change is the path define
cp object detection/packages/tf2/setup.py .
it should be object_detection like below
copy '.\object_detection\packages\tf2\setup.py' .
check this website for more details
copy "object detection\packages\tf2\setup.py" .
Try this command

Elm install always fails with "ConnectionTimeout" error (in WSL)

I'm new to Elm. and I'm not good at English. So, if any ambiguous or wrong thing is there, please let me correct it.
----------- edit -----------
All my problem below is on WSL. when I'm trying on windows, all work fine. then... why elm install doesn't work on WSL? did you have any idea?
-------- problem --------
when I try to elm-test init, it doesn't work like below
$ elm-test init
Here is my plan:
Add:
elm/random 1.0.0
elm-explorations/test 1.2.2
Would you like me to update your elm.json accordingly? [Y/n]:
-- PROBLEM DOWNLOADING PACKAGE -------------------------------------------------
I was trying to download the source code for elm/random 1.0.0, so I tried to
fetch:
https://github.com/elm/random/zipball/1.0.0/
But my HTTP library is giving me the following error message:
ConnectionTimeout
Are you somewhere with a slow internet connection? Or no internet? Does the link
I am trying to fetch work in your browser? Maybe the site is down? Does your
internet connection have a firewall that blocks certain domains? It is usually
something like that!
but my Browser(Chrome) is working beautifully, and even in WSL (the environment that I run elm-test init command at) is too.
$ curl https://github.com/elm/random/zipball/1.0.0/
https://codeload.github.com/elm/random/legacy.zip/1.0.0<body>You are being redirected.</body></html>
then I also try again to redirect the URL
$ curl https://codeload.github.com/elm/random/legacy.zip
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
I think there's no Network Problem. My PC can connect with the repo, and I think it will be downloaded well.
I lastly tried just elm install, and that throws the same error too. it seems like Elm can't connect with the repo, even if My PC can.
$ elm install elm/random
Here is my plan:
Add:
elm/random 1.0.0
Would you like me to update your elm.json accordingly? [Y/n]:
-- PROBLEM DOWNLOADING PACKAGE -------------------------------------------------
I was trying to download the source code for elm/random 1.0.0, so I tried to
fetch:
https://github.com/elm/random/zipball/1.0.0/
But my HTTP library is giving me the following error message:
ConnectionTimeout
Are you somewhere with a slow internet connection? Or no internet? Does the link
I am trying to fetch work in your browser? Maybe the site is down? Does your
internet connection have a firewall that blocks certain domains? It is usually
something like that!
Please help me, what should I do?
I recently had reason to use WSL for elm development. It wasn't much fun and I'm glad to be back on Mac! What I found was that certain disk operations on WSL seemed to go very slowly and that could lead a variety of weird issues.
I was using Webstorm, which does not handle WSL well, so in the end I did everything on C: drive (rather than in /home/...) so that webstorm could run the windows version of elm-format, while my node development environment was run on the linux layer.
That's not a precise answer to your question but just to say that it can be done, but its not an ideal way to write Elm code in my experience
I had same issue and it was solved.
It was due to DNS server settings.
Create a file /etc/resolv.conf and write the following line.
nameserver 8.8.8.8
Then WSL will refer to Google Public DNS and works fine.
However, when restart WSL, the settings revert back.
Therefore, the following settings are also required.
Create a file /etc/wsl.conf and write the following line.
[network]
generateResolvConf = false
wsl --shutdown and restart WSL.
Reference link
https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021

Segmentation Error: Local Machine Fails (16gb) but AWS EC2 works (1gb)

I understand this is a little vague but not sure where else to go to or things to debug. My python script was running fine yesterday. I made minor changes today and now it only runs successfully on my Amazon LightSail (ec2) machine. Everything I read about segmentation errors is that there is not enough memory, however my local machine has 16gb of ram while the cloud machine only has 1gb. Plus I am not working with big files? The files being imported/manipulated are typically under 2mb and there are like 7-10 files.
I feel it may be something related to my terminal/zsh rather than my codes.
The below is the error code I can not seem to manage to get around.
I've done enough research to find the python faulthandler module import faulthandler; faulthandler.enable() to give the debugging below:
Fatal Python error: Segmentation fault
Current thread 0x000000010c58edc0 (most recent call first):
File "/Users/garrett/opt/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/generic.py", line 1795 in <genexpr>
File "/Users/garrett/opt/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/generic.py", line 1797 in <listcomp>
File "/Users/garrett/opt/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/generic.py", line 1797 in count
File "GmailDownloader.py", line 215 in <module>
zsh: segmentation fault python *.py
The code seems to regularly break on line 215 while trying to compute a gorupby in pandas but it is very similar to other groupbys in the code that were successful before it.
I am on a Mac Catlina using the pre-baked zsh for my terminal handling but even when I switch to good ol' bash using chsh -s /bin/bash in my terminal and then running the code I still get a zsh segmentation error.
I have recently tried out PyCharm today and it asked for permissions to store something in a bin folder to which I just said yes. I'm not sure if that is correlated at all or not.
The full code repository: https://github.com/GarrettMarkScott/AutomotiveCRMPuller
Ongoing list of other things I have tried:
Trashing the Terminal preferences (~/Library/Preferences/com.apple.Terminal.plist)
I almost threw in the towel but tried to reinstall my pandas since it was mentioned in my bug error and what do you know it worked after running pip install --upgrade pandas
Would of been impossible without the FaultHandler! Hopefully this helps someone out there!

Creating network files in SUMO using NETCONVERT

Problem when calling netconvert in sumo:
I am trying to create my own scenario for simulation purposes.
I am using OpenStreetMaps for this.
python osmWebWizard.py
opens the browser and I select the area which I download.
netconvert --osm-files osm_bbox.osm.xml -o osm.net.xml
The error message I get is
Error: Cannot import network data without PROJ-Library. Please install packages proj before building sumo
Warning: Environment variable SUMO_HOME is not set, using built in type maps.
Quitting (on error).
My attempt to fix the problem is:
sudo apt-get install libproj*
But it seems like a dead end there and I am out of options.
Thank you.
EDIT
I have a gut feeling it has to do with libproj0 not being available anymore.