Linux function in Jupyter Notebook running in Windows - python

I am writing this code in my jupyter notebook but it is not working.
!tail -n 10 Customers.csv
The error is
'tail' is not recognized as an internal or external command,
operable program or batch file.
I am also attaching an image for the reference.
enter image description here

I installed sed, awk, grep, tar, wget exc.. from here: http://gnuwin32.sourceforge.net/packages.html .
and I installed tail, chmod, mkdir exc.. commands from here: http://gnuwin32.sourceforge.net/packages/coreutils.htm
I tested, commands are running in jupyter notebook under windows OS but there is a mini problem: For example After running the sed command, it leaves a file with a name starting with sed, ( it is like sed_fdgdfgdf ) it is necessary to delete these files.
NOTE: Download complete package and run *.exe file

This post recommends installing WSL or Git Bash.

Related

'wget' is not recognized in Jupyter Notebook, but runs in Command Line

I recently installed wget, both from https://eternallybored.org/misc/wget/ and also using
pip install wget
I put the wget.exe file in C:\Windows\System32, and when I type
wget -h
into the command line, it runs perfectly fine, and returns the help list for wget. However, when I run wget from jupyter notebooks using the code below,
!wget https://raw.githubusercontent.com/MicrosoftDocs/mslearn-introduction-to-machine-learning/main/Data/ml-basics/grades.csv
df_students = pd.read_csv('https://raw.githubusercontent.com/MicrosoftDocs/mslearn-introduction-to-machine-learning/main/Data/ml-basics/grades.csv',delimiter=',',header='infer')
df_students.head()
I get: 'wget' is not recognized as an internal or external command, operable program or batch file.
I have done quite some research now and none of the solutions seem to be working for me. I have a slight suspicion it might have to do with my system PATH variables but I can't seem to understand why Jupyter Notebooks cannot find wget.
Use curl instead:
!curl https://raw.githubusercontent.com/MicrosoftDocs/mslearn-introduction-to-machine-learning/main/Data/ml-basics/grades.csv
df_students = pd.read_csv('https://raw.githubusercontent.com/MicrosoftDocs/mslearn-introduction-to-machine-learning/main/Data/ml-basics/grades.csv',delimiter=',',header='infer')
df_students.head()
The Output:
Name,StudyHours,Grade
Dan,10,50
Joann,11.5,50
Pedro,9,47
Rosie,16,9
.....

make' is not recognized as an internal or external command Windows 10 Anaconda

I am trying to run a biostars page on my laptop. Example.
I am following the installation instructions on this here.
I have followed everything up until the line make forum demo
I get this error when I run this command.
'make' is not recognized as an internal or external command,
operable program or batch file.
I have looked for an answer and found this question.
The top answer in this question says that I might be missing options, but I am not sure about what these options are.
Any help appreciated.
You need to install mingw in your pc
following are the steps to install mingw in windows and start biostar server
install mingw-get-setup.exe
open C:\MinGW\bin\mingw-get.exe
install mingw32-make
coppy all contents from "C:\MinGW\bin" to the folder which has "makefile"
open cmd from your folder path
execute "mingw32-make forum demo" command in cmd

how to run this on Windows as it needs "source venv/bin/activate" and "flask run"

I need to try to run this https://github.com/dhavalhparikh/werewolf_web_app
there are instructions - but they are for Linux/MacOS
I am on Win10
I am stuck when I try to run
(venv) C:\PyCharm\QA_testing_419\venv\werewolf_web_app-master>source venv/bin/activate
'source' is not recognized as an internal or external command,
operable program or batch file.
also when I try to do
(venv) C:\PyCharm\QA_testing_419\venv\werewolf_web_app-master>export FLASK_APP=run.py
'export' is not recognized as an internal or external command,
operable program or batch file.
and
(venv) C:\PyCharm\QA_testing_419\venv\werewolf_web_app-master>flask run
'flask' is not recognized as an internal or external command,
operable program or batch file.
any advice?
I am in PyCharm ... but can be in any IDE
Let me try and help you if I can. (I'm also a beginner here!)
source venv/bin/activate
On windows, you should look for the activate.bat file which should be inside the bin (Ooops, Scripts folder for windows) folder. You just have to run the activate.bat file not use source command.
Edit : Inside the folder where you downloaded the app and created the venv, go to the venv folder, then to Scripts folder, then execute the "activate.bat" file. This should show that your virtual environment is active from the "(venv)" added before your drive and directory path. After this, go back to the app's root folder where requirements.txt is found then pip-install the requirements. (I tried it on my machine, I get install errors on Python 3.8 while installing requirements. Maybe it was written for Python 2.x?)
export FLASK_APP=run.py
Again on windows, it's 'set FLASK_APP=run.py' not export
flask run
If the two steps above have been done correctly (and without any install errors), above command should work.

Can I run python scripts in colab?

I am trying to get some open source software working. It uses things that I don't have on my system (pytorch for example) and so I thought that I could try to run it on Google Colab.
When I tried to do it though, there are some python scripts that I have to run after cloning a directory from a github repository. I guess I can't run another python script from inside a Jupyter Notebook, and so I suppose that I'm trying to do something with Colab that it isn't designed to do?
Is there something available that is more like a terminal, but using the software, GPUs etc. that are available on Colab?
You can run any shell command from jupyter-like environment (which includes colab) using ! in code cell, for example
!ls
Would list all files in colab's cwd.
To run python script you could do:
!python script.py
It works just like terminal (it might be python3, not sure how it's setup un colab)
You can call your script too.
!python script.py
But you need to put the script there, probably by git clone or direct uploading.
As Wayne mentions in the comment korakot's answer, you can use the magic command
%run 'script.py'
This also allows you to do e.g. run in the notebook's namespace by using the -i parameter
%run -i 'script.py'

How to execute Kaggle Api commands on windows system?

I'm referring to https://github.com/Kaggle/kaggle-api
I tried executing the sample commands listed on the page in windows CMD and Python's IDLE. Not sure where it should be executed or how can I go to Kaggle CLI?
Eg. command: kaggle datasets list -s demographics
Windows CMD says: 'kaggle' is not recognized as an internal or external command,
operable program or batch file.
Assuming the Kaggle API has been successfully installed using pip and the python install location along with the location of the Scripts\ folder have been added into the PATH; the execution of kaggle directly within Windows command prompt (CMD) should be able.
In order to ensure Python and the folder Scripts\ have been added into the PATH execute the command WHERE python3 succeeding WHERE kaggle.
If any of the two commands above produce an equivalent output of INFO: Could not find files for the given pattern(s) manually modify the PATH using the directions in Excursus: Setting environment variables to add both python install location and location of the Scripts\ folder.
You can run Bash commands on Windows using the Bash shell, which is a little tricky to launch the first time. You can find instructions on how to do that here: https://www.windowscentral.com/how-install-bash-shell-command-line-windows-10
Hope that helps! :)

Categories

Resources