jupyter / help

:sparkles: Need some help or have some questions? Please visit our Discourse page.
https://discourse.jupyter.org
291 stars 97 forks source link

No unix command working in Jupyter Notebook using ! character #203

Open firdos4u opened 7 years ago

firdos4u commented 7 years ago

I am not able to run any unix command in notebook using !

Error: command is not recognized as an internal or external command, operable program or batch file.

image

minrk commented 7 years ago

What do you get from %env, especially PATH? What OS and Python version are you using?

takluyver commented 7 years ago

That looks like a Windows error. On Windows, ! runs Windows commands.

firdos4u commented 7 years ago

%env.txt @minrk I am using windows 10 OS. While creating notebook, I am selecting Python 3. On running %env, I am getting following 'PATH': 'C:\Users\Firdaus\Anaconda3\Library\bin;C:\Users\Firdaus\Anaconda3\Library\bin;C:\Users\Firdaus\Anaconda3;C:\Users\Firdaus\Anaconda3\Library\mingw-w64\bin;C:\Users\Firdaus\Anaconda3\Library\usr\bin;C:\Users\Firdaus\Anaconda3\Library\bin;C:\Users\Firdaus\Anaconda3\Scripts;C:\Users\Firdaus\Anaconda3\Library\bin;C:\Program Files (x86)\Intel\TXE Components\TCS\;C:\Program Files\Intel\TXE Components\TCS\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Users\Firdaus\Anaconda3;C:\Users\Firdaus\Anaconda3\Scripts;C:\Users\Firdaus\Anaconda3\Library\bin;C:\Users\Firdaus\AppData\Local\Microsoft\WindowsApps;',

minrk commented 7 years ago

Oh, yeah. On Windows, you aren't going to find unix commands because it's Windows. Do you see those commands as being available when you run a cmd shell?

denisBK commented 6 years ago

Is it possible to "emulate" running UNIX commands on Jupyter notebook that is installed on windows?

takluyver commented 6 years ago

You can run the notebook inside a Linux virtual machine (e.g. with Virtualbox), or inside the new 'Windows Subsystem for Linux', which acts a lot like a virtual machine, though it works differently.

There are also projects like Cygwin that try to provide a Unix-like environment on Windows, but we don't really try to support that. It's neither fully one thing nor the other, which makes it confusing.

leandroamoras commented 6 years ago

Hi, for people taking the UCSD course: I think there's a lot of confusion on your ends. Also I didn't notice before but from the OP first screenshot, you don't do !ls in Git Bash itself - it's simply ls. The ! before a unix command is only in the Jupyter Notebook web interface.

Here's a step by step of my setup:

Install Git Bash - at installation select the optionUse Git and the optional Unix tools from the Windows Command Prompt. Install Anaconda. Uncheck all boxes in the advanced installation screen - see this image. Launch Git Bash. It should open in your user directory (ex: C:\Users\Bob). In the Git Bash terminal activate the Anaconda environment with the command: source Anaconda3/Scripts/activate Anaconda3/ cd into the folder where the course notebooks are. Example: cd Projects/dse200x/week-3/week-3-unix/ Run jupyter notebook and your browser should open with Jupyter in the current directory. When finished, shutdown Jupyter in your terminal with ctrl+c and close the terminal window. Like mentioned in my previous comment, you'll have to modify the sed command and the "deleting empty lines" bit as it behaves differently:

The problem I had was with sed and deleting empty lines as Jupyter calls CMD.exe

Credits: @cristovaov

NielsHaw commented 6 years ago

Hi, This solution does not seem to work for me:

When I type: source Anaconda3/Scripts/activate Anaconda3/ it says: invalid syntax.

However, when i just type python it does not give me an error.

But then, when i want to cd into the folder where the course notebooks are. This does not work either: it also says invalid syntax

What do I need to do?

kirangupta23 commented 6 years ago

Hi Guys,

This Solution worked for me: conda install posix

riddhitokdar commented 5 years ago

Hi Guys,

This Solution worked for me: conda install posix

This worked fine for me. Thank you