Why can't I invoke python from the command line? - windows-vista

I have Python 2.6 installed on Windows Vista. If I am at C:\Python26> and I type python, Python's command-line interface starts, as desired.
I have added C:\Python26 to my PATH so that I would be able to run Python scripts from any directory, but it hasn't helped. In particular, from any other directory, the command python is not recognized.
I appreciate any guesses as to what change would get this working.
Edit: First, I have re-opened my cmd window (several times) so that is not the issue.
To clarify how I added C:\Python26 to the PATH, I clicked the following:
Computer -> System Properties -> Advanced system settings -> Environment Variables
at the point I select PATH and click Edit. I added C:\Python26 to the Variable Value field, separating this from the previous entries with a semicolon. Then I click OK a few times.
Edit #2 I've now checked my PATH by typing path at the command prompt. C:\Python26 is certainly in the path. I'll reboot anyway, and see if that helps.

This still sounds like a path issue.
If you have just added c:\Python26 to your path, then you need to open a new cmd window before those changes take effect, they won't apply to your existing cmd windows.
If you're unsure how to do this in Windows Vista, here is the instructions.
Select Settings -> Control Panel from the start menu.
Double click the 'System' icon.
Choose 'Advanced System Settings' on the left hand side.
Choose 'Environment Variables'
In the bottom list, select 'Path', and click 'Edit...'
At the end of the path string, add ;C:\Python26, leaving everything else the same, then click OK, then click OK again on the various windows still open.
Now open a new cmd window, and try the 'python' command from any directory - it should work.
This may be obvious to most people, but hopefully anyone with the same problem will find the help they need in this answer.

if you are certain that you have added the directory to the path, you may just need to open up a new command window for it to take the changes to the current path.

Double and triple check that you added the path correctly and didn't make a typo.
Restart your machine.

In the top panel where it says User Variables for YOUR NAME HERE,
select path, click the top edit button.
Append ";C:\Python26" without quotes at the end of the text in the "Variable Value" textbox.
That solved the problem for me.

Other options are to reinstall or to create a .bat file with c:\python26\python.exe and put that in your path

Related

How to use a specific command in all directories?

Note: I am sorry if I posted this in the wrong stack exchange website. I have seen similar questions on this website. Please correct me if it was wrong.
So I installed VLC into the directory D:\misc\vlc and when I type "vlc" into command prompt, it starts the VLC media player. However, I want to run this "vlc" command in the directory D:\slam\ . However, every time I do that, it says that "'vlc' is not recognized as an internal or external command,
operable program or batch file.".
Is there a way to run the 'vlc' command in any directory?
Any help is appreciated.
You can add the vlc program to the PATH in Windows using the "Edit Environment Variables" dialog. Assuming Windows 10 (though this dialog is present in older versions too), here is how to add a program to the PATH:
Open the Start Search, type in “env”, and choose “Edit the system environment variables”
Click the “Environment Variables…” button.
Under the “System Variables” section (the lower half), find the row with “Path” in the first column, and click edit.
The “Edit environment variable” UI will appear. Here, you can click “New” and type in the new path you want to add. From this screen you can also edit or reorder them.
Dismiss all of the dialogs by choosing “OK”.
Your changes are saved! You will probably need to restart apps for them to pick up the change. Restarting the machine would ensure all apps are run with the PATH change.
In step 4 above, the new path that you will type is the directory containing the vlc program, e.g. "D:\misc". Note that adding this directory will also make any other programs inside of the "misc" directory accessible as well.

How to configure ConEmu to start with gitbash and on a specific directory

I just installed the ConEmu terminal, and I am having trouble configuring it to start with gitbash as my terminal instead of the windows CMD, and I would like it to start on ex: /c/Users/Kalin/Drive
I tried to randomly pass values to the settings since they are very hard to understand. I have no idea what {Shell::cmd} means in the "tasks" category (which I guess is the place to change the configs) but I have no idea. The whole thing looks like something from a commercial aircraft and I'm lost :)
You can try the following step-by-step instructions:
Open the settings menu.
Go to Startup -> Tasks in the left pane
Click the + at the bottom of the list of "Predefined tasks (command groups)"
In the big textbox, enter:
c:\path\to\gitbash.exe -new_console:d:/c/Users/Kalin/Drive
Save settings
The key thing to recognise is that this is the minimal config. To begin with, you will ignore all the options. When you want to do the next tweak, then look for it in the manual.
In the latest version, this configuration is more simplified. Just do as follows
Go to {Bash:Git bash} predefined task
In the big text area, keep your cursor to the end of the prepopulated text, so that it is right after -new_console:d: text
Below the big text area, you will see the following options
Add: Tab... | Startup dir... | File Path ... | Active tabs
Just pick your startup directory from Startup dir... option
Restart ConEmu and you will see the session starts with the startup directory you have configured.
NameGoesHere's answer worked for me. I just had to make one modification on the fourth step:
When you set your directory you need to use "new_console:d:c/Users/Kalin/Drive", whithout the bar after "new_console:d:".
Rather the simple way must be to add the path under Task Parameters as
/dir "C:\Dir\subDir....."

How do I add Ruby to the PATH variable on Windows?

I have Ruby installed, but I still need to add it to the PATH variable. I found something online for how to manually add it using the command line:
set PATH=C:\Ruby200-x64\bin;%PATH%
But before I try it, I want to be sure it's not going to overwrite what's currently in the PATH variable. (I have no experience with this stuff so I don't know what to expect).
Thanks in advance for your help!
first, notice that this question is not really about Ruby, rather about how to set a path in windows (it work the same way if you want to add an executable different from Ruby)
second, you are not overwriting the PATH environment variable because you add the existing content of the same to the new one you are setting in:
set PATH=C:\Ruby200-x64\bin;%PATH%
the %PATH% is the current content of the PATH variable.
Consider using
set PATH=%PATH%;C:\Ruby200-x64\bin
instead, this will make your OS search the original path before searching the ruby bin folder. Maybe it makes few difference on modern computers, but my old DOS days claim the second solution is better.
third and last point, in Windows you can set environment variables in control panel / system properties
How to get there depends on the version of your OS, but if you search for the ambient variables and system variables you should get there.
From the Desktop, right-click the very bottom left corner of the screen to get the Task Menu.
From the Task Menu, click System.
Click the Advanced System Settings link in the left column.
In the System Properties window, click on the Advanced tab, then click the Environment Variables button near the bottom of that tab.
In the Environment Variables window (pictured below), highlight the Path variable in the "System variables" section and click the Edit button.
Add or modify the path lines with the paths you want the computer to access. For ruby it will be:
;YOUR_RUBY_INSTALLATION_PATH\bin;
The operation with set PATH=C:\Ruby200-x64\bin;%PATH% is probably only temporary until you restart your computer.
I just wanted to let everyone know that when you install rubyinstaller on Windows and follow its steps, there is no option to 'add to path variables' because it automatically adds it.
Rubyinstaller trolled me hard because it said gem not found when I did gem install sass immediately after install.
Your path variable is probably already set if you used rubyinstaller.
The trick is to open CMD or I would imagine, PowerShell, ConEMU, etc, git bash, and type gem.
Press WINKEY and type cmd
Type gem install sass (or whatever else that is in the bin folder for Ruby)
I just went to add the PATH variable, and it was already set, so my problem was the garbage command line tool that opened after installing rubyinstaller.
You can also do these steps to add to the PATH variables:
Press WINKEY
Type view advanced system settings
Open that
Click Environment Variables
Click Path in the list
Click Edit
Check if C:\Ruby24-x64\bin is already there, if so, done
Click New and type in C:\Ruby24-x64\bin
Done
Yes, this is correct. In your example %PATH% will be expanded to the current value of the PATH variable, so this command is effectively adding a new entry to the beginning of the PATH.
Note that calling set PATH will only affect the current shell. If you want to make this change permanent for all shells, the simplest option is to set it as a user variable using the Environment Variables dialog box.
On Windows 8 you can open this dialog by hitting Win+s and searching for 'environment variables'. On earlier versions of Windows you can right-click 'My Computer', choose Properties, then Advanced system settings, then Environment variables. You can create (or update) a PATH variable in the user variables section and add whatever entries you need. These will be appended to the existing system path. If you take this approach you will need to open a new cmd shell after updating the variables.
Fear nothing, What you are doing is prepend C:\Ruby200-x64\bin to the existing %PATH%, this is what the command you posted does.
The path is a list of directories, separated by ;, in which the system will look for the command you execute.
In your case it's:
C:\Ruby200-x64\bin
%PATH%, if you print it on the command line, you'll find it's itself a list of directories separated by ;.
In case you want to make your change permanent, you have to change your PATH sytemwide.
For CLI, as noted elsewhere calling SET on the path variable only acts on the current window and closing it or restarting windows voids the change.
Example the transient Version selected as the answer:
set "PATH=%PATH%;C:\Ruby200-x64\bin"
To correctly set the path permanently in CLI use the path command:
PATH %PATH%;C:\Ruby200-x64\bin
This will persist between CMD windows and after reboots.
I know this is questions has the Windows tag, however it is one of the first DuckDuckGo results for "ruby gems add to path" so I just wanted to add this.
On Linux you can add this line to the end of your .bashrc in order to add it to your path:
export PATH=$PATH:~/.gem/ruby/2.6.0/bin

git-cheetah modifying path environment variable multiple times

Just wanna find out if anyone has had a similar experience to this.
Git seems to be modifying my path environment variable, hereafter referred to as $path, such that if after having my system running for a few days the $path is 1 huge mess!
After a clean boot $path looks something like this:
D:\WINDOWS\system32;D:\WINDOWS;D:\Apps\Development\Git\cmd;D:\Apps\Development\Android\android-sdk\platform-tools;D:\Apps\Development\phantomjs-1.9.7-windows;D:\Apps\Tools\GnuWin32\bin
When it gets to the state I mentioned it looks something like this:
D:\Apps\Development\Git\git-cheetah..\bin;D:\WINDOWS\system32;D:\WINDOWS;D:\Apps\Development\Git\cmd;D:\Apps\Development\Android\android-sdk\platform-tools;D:\Apps\Development\phantomjs-1.9.7-windows;D:\Apps\Tools\GnuWin32\bin
Except that the D:\Apps\Development\Git\git-cheetah..\bin bit is repeated, sometimes (what looks like) over 50 times!
Any insight into this would be much appreciated
First of all, apologies that this is more of a workaround than an answer. I am experiencing the same exact issue. Eventually my PATH gets so large that my programs can't find anything, even as simple as XCOPY.
This is happening to me on my work computer which is under domain control and I don't have admin permissions. These instructions assume no admin access, strictly user access.
In order to avoid restarting I perform the following:
Prior to performing these steps you can open command window and run set PATH to verify that you have too many cheetahs.
Go to the Environment Variables dialog (Right-Click "My Computer" -> Choose "Properties" -> Select the "Advanced" tab -> Click the "Environment Variables" button).
Select "PATH" variable under the "User variables for <username>" section.
Click then "Edit" button under the same section.
Do nothing
Click OK in the "Edit User Variable" dialog box.
Click OK in the "Environment Variables" dialog box.
Click OK in the "System Properties" window.
Open a NEW command window (command windows that were already open may preserve their current environment) and run 'set PATH' to verify that you're back to none or one 'cheetah's in your path.
I had the same annoying problem. Just download git-cheetah source, open common/winexec.c and on line 262 change from:
if (path.len) {
setenv("PATH", path.buf, 1);
rec->envpath = strbuf_detach(&path, NULL);
}
to:
if (path.len) {
if (!strstr(getenv("PATH"), gitpath))
setenv("PATH", path.buf, 1);
rec->envpath = strbuf_detach(&path, NULL);
}
Then, recompile (cd explorer, mingw32-make) and copy the generated dll over the existing one in Program files\Git\git-cheetah. If the file is in use you can open a console window, close the Explorer process and copy using command line; then, restart explorer using the task manager (File->Execute).

Where is the path information in DOS saved

I had recently entered set path = c:\TC\bin;%path%. Thereafter entering path got this path = c:\tc\bin;BLAH-BLAH; and it worked. I closed command and reopened it does not work and on checking I get path=BLAH-BLAH; only. The recent addition I made was not present. Any clues? Thanks.
Environment variables are saved in a registry setting.
When you edit an environment variable in a command shell, the change only applies to that command shell (as you found).
If you want to set the path for the whole system you need to set it centrally - in Windows XP you can right click on "My Computer", choose "Properties", "Advanced" then click on "Environment Variables" at the bottom, and similar methods apply to other Windows sytems.
If you want to edit it programmatically you would need to do this through the registry APIs. There are answers about how to do this here: Programmatically modifiy environment variables?

Resources