I am a Windows user, I want to use octave in the terminal of vscode.
I have put octave to the environment variable, but when I type octave in the terminal, it pop out the gui version.
I have tried to type octave --no-gui, it pop out the octave-cli window (Please refer to the image attached).
Here are the questions:
How can I use octave-cli in the terminal of vscode?
Can I disable octave use gui when I type octave or I can only type octave --no-gui to use cli version?
In addition to the octave.vbs file that most people use to start octave, there is also an octave.bat file located under %OCTAVE-HOME%/mingw64/bin.
I'm not familiar with vscode, but if I open a Windows command prompt, navigate to c:\Octave\octave-6.4.0-w64\mingw64, and type octave.bat (no options used), it opens octave in the existing window.
Run Octave in VSCode Jupyter Notebook
You can change line octave-cli.exe % to octave-gui.exe --no-gui % in file octave.bat:
Rem Start Octave (this detaches and immediately returns).
if %GUI_MODE%==1 (
start octave-gui.exe --gui %*
) else (
octave-gui.exe --no-gui %*
Rem octave-cli.exe %*
)
Instead of starting octave-cli.exe you are starting GUI octave-gui.exe --no-gui without graphical use interface.
Check available graphics toolkits in octave:
octave> available_graphics_toolkits()
Answer should be
ans = {
[1,1] = fltk
[1,2] = gnuplot
[1,3] = qt
}
Check which graphics toolkit is used
graphics_toolkit()
ans = qt
Answer should be qt.
Benefit of the change is that now you can use best inline graphics in Jupyter Notebooks and also in VSCode Jupyter Notebooks.
John
Related
The Anaconda command prompt looks like normal windows command prompt and its start menu shortcut traces back to the cmd.exe file on windows in the C:\Windows\System32 directory, so I know it is just an instance of the command prompt with certain other characteristics or features. I am curious as to what all these other aspects are.
When I click on properties of the "Anaconda Prompt" shortcut, the target is "%windir%\System32\cmd.exe" /K" C:\ProgramData\Anaconda3\Scripts\activate.bat C:\ProgramData\Anaconda3 so it has some extra arguments. In those arguments is the difference between opening a vanilla command prompt and an Anaconda.
Breaking down these commands, the /k option appears to be described here and here to mean run the command and return to the prompt, although those references refer to a lower case /k.
The next argument points to a bat file to activate an Anaconda script. Then it passes a path to a directory called "Anaconda3". I am fairly certain the path it passes as the final arg means it wants this path to be accessible as if it were in the user or system path environmental variable. Python.exe (Python 3) is in this directory, as well as a _conda.exe and an important Scripts folder, so if we don't have our python in the system or user path, this is how it is found, I am fairly certain.
Back to the .bat file, this does a lot of things. I always though bats were binaries, because of how they acted on the system, but they're really just like Bash Scripts for Windows. They are human readable and mine is as follows:
#set "_args1=%1"
#set _args1_first=%_args1:~0,1%
#set _args1_last=%_args1:~-1%
#set _args1_first=%_args1_first:"=+%
#set _args1_last=%_args1_last:"=+%
#set _args1=
#if "%_args1_first%"=="+" if NOT "%_args1_last%"=="+" (
#CALL "%~dp0..\condabin\conda.bat" activate
#GOTO :End
)
#REM This may work if there are spaces in anything in %*
#CALL "%~dp0..\condabin\conda.bat" activate %*
:End
#set _args1_first=
#set _args1_last=
This .bat calls another .bat, "conda.bat", in a nearby directory with it's own code:
#IF NOT DEFINED _CE_CONDA (
#SET _CE_M=
#SET "CONDA_EXE=%~dp0..\Scripts\conda.exe"
)
#IF [%1]==[activate] "%~dp0_conda_activate" %*
#IF [%1]==[deactivate] "%~dp0_conda_activate" %*
#SETLOCAL EnableDelayedExpansion
#IF DEFINED _CE_CONDA (
#REM when _CE_CONDA is defined, we're in develop mode. CONDA_EXE is actually python.exe in the root of the dev env.
FOR %%A IN ("%CONDA_EXE%") DO #SET _sysp=%%~dpA
) ELSE (
#REM This is the standard user case. This script is run in root\condabin.
FOR %%A IN ("%~dp0.") DO #SET _sysp=%%~dpA
IF NOT EXIST "!_sysp!\Scripts\conda.exe" #SET "_sysp=!_sysp!..\"
)
#SET _sysp=!_sysp:~0,-1!
#SET PATH=!_sysp!;!_sysp!\Library\mingw-w64\bin;!_sysp!\Library\usr\bin;!_sysp!\Library\bin;!_sysp!\Scripts;!_sysp!\bin;%PATH%
#SET CONDA_EXES="%CONDA_EXE%" %_CE_M% %_CE_CONDA%
#CALL %CONDA_EXES% %*
#ENDLOCAL
#IF %errorlevel% NEQ 0 EXIT /B %errorlevel%
#IF [%1]==[install] "%~dp0_conda_activate" reactivate
#IF [%1]==[update] "%~dp0_conda_activate" reactivate
#IF [%1]==[upgrade] "%~dp0_conda_activate" reactivate
#IF [%1]==[remove] "%~dp0_conda_activate" reactivate
#IF [%1]==[uninstall] "%~dp0_conda_activate" reactivate
#EXIT /B %errorlevel%
As I expected, when I called the activate.bat file in an ordinary (admin) command prompt, it turned into an Anaconda prompt with the "(base)" prefix before my current path you get when you click the startup shortcut. (base) C:\Users\User>. Interestingly, doing this only seems to work in the regular command prompt, not Git Bash, not WSL, not even Powershell, though there is a separate Powershell launcher that works. In its properties, it has the target:
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\ProgramData\Anaconda3' "
And if you run the ps1 file (a powershell like script), it has the same effect of putting you into the conda environment, because you can run the 'conda' command and help instructions appear.
Here is the ps1 code.
$Env:CONDA_EXE = "C:/ProgramData/Anaconda3\Scripts\conda.exe"
$Env:_CE_M = ""
$Env:_CE_CONDA = ""
$Env:_CONDA_ROOT = "C:/ProgramData/Anaconda3"
$Env:_CONDA_EXE = "C:/ProgramData/Anaconda3\Scripts\conda.exe"
Import-Module "$Env:_CONDA_ROOT\shell\condabin\Conda.psm1"
Add-CondaEnvironmentToPrompt
Anyway that's just kind of the background context, which I learned in the last few hour researching, because I wanted to do my homework. I wanted and want to know is what Conda is doing in Windows when you open the Command Prompt through Anaconda. I'm pretty certain it is doing two main things: setting the path to include the C:\ProgramData\Anaconda3 directory, for the session, and activating it's base environment or any other virtual environment you tell it to launch that you may have created through it at some point, but does it do anything else of note?
I ask this not just because I am curious about what's really going on (I am), but I was also hoping to work with Conda in Git Bash and WSL, terminals I really like. I can currently use Conda's Python with them (the only Python on my machine) as it seems to exist independent of the program that installed it and manages packages for it, but I was specifically hoping to use the all the Conda environment management tools inside Git Bash or WSL. After thinking about it, I now don't believe this is possible. From a naive user perspective, one sort of assumes they can run any program anywhere, and that makes sense or would have made sense before we had sub-systems and systems within systems, but from a more aware point of view, Anaconda was installed for Windows and inside the C:\ProgramData\Anaconda3 directory are .exe and .bat files, not Linux/WSL compatible binaries and .sh or .bash files. It's like trying to run Windows_OS>Linux subsystem>Windows_file_again, but it doesn't work like that. WSL and Git Bash don't even have the same path structure somehow. Am I right in my thinking so far?
I enjoy Git Bash and WSL more than Powershell or cmd and I use them a lot for GCC and git. I do most of my coding in VS Code and launch these terminals there. I suppose at best I could install conda for git bash or wsl if such a thing existed, but even then it might not be able to talk to my main Conda or share environments. Otherwise I could either trying using venv for an environment, as that appears to work in these shells through python, or just use the normal command prompt to do everything if I really want to use Conda.
Am I right in my assessments?
Thanks for sticking with me! To get good at something, you have to get to the point where it's all plainly obvious, otherwise you run the risk of being lost and confused at a time you least want to be.
Edit: Now that I'm back at it, I rediscovered my original hurdle: the fact couldn't use Conda's command prompt straight from the VS Code or how to activate it once I booted the normal command prompt. Now I know about the .bat startup script at least and could in theory activate it that way each time, but it's kind of awkward, or I could launch a prompt externally and navigate to my working directory, but that's clumsy too. I forgot that this was my first blocker, and on a related note I had similar issues with x64 Native Tools (a Visual Studio based command prompt). I wondered what that was as well, why it looked like an independent terminal but I couldn't launch it in VS Code.
For WSL, yes you are right. Running the conda that you installed for windows would be the same as trying to run any other program that you installed for windows -> it will fail because the binaries are not compatible. You would probably be able to install the linux version there, but as you pointed out, that is not what you want.
For git bash, the solution is more simple than you might think. You can set it up so that you can "talk"to your windows installed conda. Yes, you will need to have the equivalent setup to what you have already discovered for cmd and powershell, but conda already has everything you need to set it up.
Assuming your installation is at C:\Users\foo\miniconda3\, from your git bash, do:
/c/Users/foo/miniconda3/Scripts/activate
conda init bash
this will modify your bash_profile to automatically set up conda for use from git bash
Some clarifications:
I now don't believe this is possible. From a naive user perspective, one sort of assumes they can run any program anywhere, and that makes sense or would have made sense before we had sub-systems and systems within systems, but from a more aware point of view, Anaconda was installed for Windows and inside the C:\ProgramData\Anaconda3 directory are .exe and .bat files, not Linux/WSL compatible binaries and .sh or .bash files. It's like trying to run Windows_OS>Linux subsystem>Windows_file_again, but it doesn't work like that. WSL and Git Bash don't even have the same path structure somehow
WSL, as you have pointed out, is a subsystem and, since wsl 2 runs a real linux kernel. It naturally follows that, as you have said, it is not possible to run windows binaries from it.
Git bash however, is not a subsystem at all. Instead, it is a port of bash for windows. That means when you are in your git bash, you are still within your windows environment. Only the syntax for paths and commands is different (see above commands I have provided), but you are still in the same system.
If you look at the file
C:\Users\foo\miniconda3\Scripts\activate
you will also see that it is a normal .sh script that calls conda.sh at
C:\Users\a-fjochhe\miniconda3\etc\profile.d\conda.sh
So ana/miniconda does indeed come with a set of sh scripts that you can use from a bash terminal in Windows
Seems like Kivy APIs are steered towards Linux systems more than anything. Has anyone success created a kivy atlas on windows using the command prompt?
If so, how is it done?
Full working code please.
Actually this manual works on Windows. You need to use console (press Win+R, type cmd and press Enter).
cd to your project folder and use the following command (with your image filenames and sizes, obviously). And it's dir on Windows, not ls, but otherwise it's the same.
python -m kivy.atlas myatlas 256x256 img1.png img2.png
This simplest way under Windows for me was the following...
Create a script with a string template of the Json code which constructs the atlas.
ImgSize = 512x512
AtlasT = """
{
"run.png": {
%s
}
}
"""
You would then create a loop, that will loop through all directories you specify, gathering all the images and formatting the template.
Save the atlas at the end. All mathematics are calculated by the script based on the size of the images.
If you use the linux terminal command as per the docs, you'll get an error. Just enter this into windows commmand line window - python - m, and hit enter. You'll get an error saying python is not recognized as an external or internal command or something like that.
Linux Ubuntu is far different from Windows. It seems like Linux is always aware of what you install so if you address something by name like, python, you'll get feed back. That's not the same under Windows. In order to use python on windows you really have to point to python.exe.
Don't bother using the kivy docs atlas command line in windows. Windows won't understand kivy.atlas either. It's not Linux!
I would like to add Octave in my PATH environment variable. Is there a lineguide like the following?
http://www.java.com/en/download/help/path.xml
Suppose you installed Octave in a folder myOctave, and the path to it is myPath which may be something like C:\Program Files\. Then, you could launch the cmd of your windows, and type the following
set PATH=%PATH%;myPath\myOctave\bin
Here is a detailed example based on my own Octave path and directory. My Octave is installed here E:\Programs\Octave\Octave-4.0.0, and thus under the cmd window, I run
set PATH=%PATH%;E:\Programs\Octave\Octave-4.0.0\bin
Then you are all set.
if you run open Command promt and type octave --gui ( it will open Graphical interface)
else if you just type octave (it will open command interface).
Just type addpath('requiredPath') in the Octave command prompt.
Since GNU Octave comes wit a GUI since versions 3.8.0, I thought I should check it out.
So since I run Windows and could only find Octave 3.8 for Cygwin, I installed Cygwin and the packages octave, xinit, xlaunch and gnuplot (according to this page, but I don't know if all those packages are needed).
Then, when trying to start Octave with the GUI from Cygwin with octave --force-gui, I initially got the error message
octave: X11 DISPLAY environment variable not set
and Octave would start in console mode. So I found this page, which told me to run
echo "export DISPLAY=:0.0" >>~/.bash_profile
from Cygwin, to permanently get rid of the error message, which worked. However, then I instead got this error message:
octave: unable to open X11 DISPLAY
The same page also said that you have to run the X Server by going to Start -> Cygwin-X -> XWin Server. That worked, but since I don't want the xterm terminal to start since it is not needed, I found this page which told me to run
touch ~/.startxwinrc
from Cygwin to create an empty .startxwinrc file, to prevent the xtrem terminal from starting by default, which worked. The same page also mentioned that the X Server can be started directly from Cygwin with the command startxwin.
So, now I can start Octave with the GUI from Cygwin, simply by running
startxwin
octave --force-gui
However, I would like to just be able to double click on a desktop icon to get everything up and running.
So, to my question: Can I somehow put this in a script file, which when I run it, will be opened in Cygwin so that the commands in the script file will be run in Cygwin? And is there some way to automatically close the X Server after Octave has terminated? I've tried writing a file octave.bat, which starts Cygwin and gives a second batch file as argument, which in turn contains the commands I want to execute. But when I run the first script, I just get bombarded with command prompts (not Cygwin prompts), and the all say
'startxwin' is not recognized as an internal or external command, operable program or batch file.
Why is the second script not opened in Cygwin, and how can I achieve what I want as simply as possible?
Please grab Octave from here: http://mxeoctave.osuv.de/
The installer should configure everything for you.
GNU Octave offers now Windows binary itself. Go to ftp://ftp.gnu.org/gnu/octave/windows/
You have to put
c:\cygwin64\bin\mintty.exe /bin/sh -lc 'startxwin /bin/octave --force-gui'
in your windows batch file (please adapt the Cygwin path to your settings). That worked fine for me.
The call
c:\cygwin64\bin\bash --login -c "startxwin /bin/octave --force-gui"
did open Octave as desired but the GUI seemed to have response issues to the keyboard and froze after clicking into the editor.
I don't have any of the those commands installed with my Cygwin installation, so I can't test this by trying using the following an .bat file on your desktop:
c:\cygwin\bin\bash --login -c "startxwin octave --force-gui"
Replace c:\cygwin with the directory where you installed Cygwin.
If this leaves a console window on the screen try doing:
c:\cygwin\bin\bash --login -c "run startxwin octave --force-gui"
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I know for linux and Unix machines there is emacs and vi text editor and gcc is built in to compile c code? what would be the Windows text editor in cmd and are there any compilers built in?
I made a simple VIM clone from batch to satisfy your needs.
#echo off
title WinVim
color a
cls
echo WinVim 1.02
echo.
echo To save press CTRL+Z then press enter
echo.
echo Make sure to include extension in file name
set /p name=File Name:
copy con %name%
if exist %name% copy %name% + con
Hope this helps :)
There is also a port of nano for windows, which is more more akin to notepad.exe than vim is
https://www.nano-editor.org/dist/win32-support/
Get the WINNT zip. Tested in Windows 7 works as expected
I want to add that it is very strange to introduce Core and Nano servers without native console full-featured editor. Like others I`ll recommend to use vim or nano. But my suggestion is to install it via OneGet (require WMF5)! They both are presented in Chocolatey repository so installation is simple and fast:
PS C:> Find-Package -Name vim | Format-Table -AutoSize
Name Version Status ProviderName Source Summary
---- ------- ------ ------------ ------ -------
vim 7.4.638 Available Chocolatey chocolatey Vim is an advanced text editor...
PS C:> Install-Package vim
MS-DOS Editor (or just edit) is a 16-bit text editor that is still included with 32-bit versions of Windows XP, Vista, 7, 8 and 8.1. It can edit files upto 65,279 lines long and has mouse support. Being an 16-bit DOS editor, it cannot run directly on 64-bit versions of Windows. It can be launched by typing edit at the command prompt.
There is no command based text editors in windows (at least from Windows 7). But you can try the vi windows clone available here : http://www.vim.org/
There is no command based text editors in windows (at least from Windows 7). But you can try the vi windows clone available here : http://www.vim.org/
You are Wrong!
If you are using Windows 7, you can using this command:
copy con [filename.???]
Or if you using Windows XP or lower, use (is have a DOS GUI):
edit
Any comment?
I also wondered what had happened to the text editor in console mode in windows. I remembered the famous mc from Linux. Of course, it's available for Windows!
GNU Midnight Commander is a visual file manager, licensed under GNU
General Public License and therefore qualifies as Free Software. It's
a feature rich full-screen text mode application that allows you to
copy, move and delete files and whole directory trees, search for
files and run commands in the subshell. Internal viewer and editor are
included.
Midnight Commander is based on versatile text interfaces, such as
Ncurses or S-Lang, which allows it to work on a regular console,
inside an X Window terminal, over SSH connections and all kinds of
remote shells.
As mentioned somewhere there are also FAR Manager
vim may be challenging for beginners. For a quick-and-dirty Windows console-mode text editor, I would suggest Kinesics Text Editor.
There actually is a basic text editor on Windows. In the command prompt simply type edit, and it should take you to there. Now, someone already mentioned it, but they said it's XP or lower. Actually it works perfectly fine on my Windows 7.
Wikipedia page
Again, I am running Windows 7, so I've no idea if it's still is present on Windows 8.
And as IInspectable pointed out, there's no built in C compilers, which is a disappointment. Oh, well, back to MinGW.
Also, "here" someone mentioned Far Manager, which has ability to edit files, so that's some alternative.
Hope that helps
You can install vim/vi for windows and set windows PATH variable and open it in command line.
As said by Morne you can use the vi editor for windows
Also you can get CodeBlocks for windows from here
Install it and direct your PATH environment variable of your windows installation to gcc or other binaries in bin folder of codeblocks installation folder.
Now you can use gcc or other compilers from cmd like linux.
There is one built into windows 7 in which you can open by clicking the windows and r keys at the same time and then typing edit.com.
I hope this helped
The standard text editor in windows is notepad. There are no built-in command line editors.
Windows does not ship a C or C++ compiler. The .NET framework comes with several compilers, though: csc.exe (C# compiler), vbc.exe (VB.NET compiler), jsc.exe (JavaScript compiler).
If you want a free alternative you can download Visual Studio Express 2013 for Windows Desktop that comes with an optimizing C/C++ compiler (cl.exe).
In a pinch, just type 'notepad (filename)' and notepad will pop up with the file you want to edit in it. Otherwise Vim or some such will have to be installed.
notepad filename.extension will open notepad editor