ipython in cmd erro - cmd

I installed ipython in cmd with pip, but when I type ipython in cmd and run it
this error comes:
'ipython' is not recognized as an internal or external command, operable program or batch file.

As #2e0byo stated in the comment, it's a windows problem, not python and you have two options to solve it:
Executing it by using the path you saved it in.
Adding it to the PATH variable so you can easily execute it from the command line.
First solution:
Go to your path using the command line. For example, my Python is saved in C:\Users\serig\AppData\Local\Programs\Python\Python39. I used cd to go to the directory I wanted and tried to run python which was successful.
Second solution:
Search for environment variables:
Click Environment Variables:
Then you have to add your python directory to the PATH variable (remember to add it to system variables - when I added it to user variables it didn't work). Click edit, then New and add your python directory:
After saving everything you should be able to run python easily without going to the directory it's saved in.
Adding to the path - source

Related

What is the difference between the PATH listed by 'env' in git-bash and the PATH in Windows 10's control panel?

My goal is to write a shell script that will ensure that a bunch of Windows 10 computers with Python freshly installed on them can run the 'python' command from a git-bash command line in Windows Terminal by having the script check the PATH environment variable and modify it if necessary.
More specifically, I want my script to check if the following three paths are part of each computer's PATH, and if they aren't already a part of it, edit the PATH so that it permanently contains them.
C:\Program Files\Python311
C:\Program Files\Python311\Scripts
C:\Users\ <localUser>\AppData\Roaming\Python\Python311\Scripts
What threw me off is that I noticed that the PATH variable that I get from the 'env' command on the git-bash command line is different from the PATH variable that I can see in Windows 10's control panel. I tried adding a junk path to PATH from the command line by typing
export PATH=/c/someNonexistentPath in git bash but it didn't change the PATH that I could see in the Windows 10 control panel. Moreover, I couldn't even see if it changed the PATH I get from running env on the command line because for some reason after you run any export command git-bash gets amnesia and refuses to recognize the env command until you start a new session of git-bash.
Shouldn't there only be one PATH on a computer? If the two seemingly different PATHs that I have mentioned are not supposed to be the same, what is the difference between them, and how can I accomplish my goal of writing the script so that it does what I need it to do?
Please let me know if I need to include any more system-specific info. Thanks in advance for your help.

Restore the previous system path variable (windows)

a question regarding messing with Windows Path variable.
My situation is quite specific:
I was trying to install ffmpeg according to this tutorial https://www.geeksforgeeks.org/how-to-install-ffmpeg-on-windows/
The last step was setting the path variable setx /m PATH "C:\ffmpeg\bin;%PATH%"
It worked, however afterwards I noticed that if I try to call python from the command prompt or the powershell if run as administrator, I started getting 'chcp' is not recognized as an internal or external command, (although works fine if run as user), indicating that something is wrong with PATH variables.
I looked into my variables and saw this edit.
Path
It seems to me that the command added the ffmpeg line to the system path and possibly overwritten the original, which is why there are issues when using command prompt as administrator. It probably should have added it to the user Path (not system Path variable)
If that is the case, is there a way to restore the previous system Path variable. Maybe I can paste it from the user Path variable?

python virtualenvwrapper producing an EOL error on install

I was trying to use the pip package
virtualenvwrapper
in Windows through gitbash. The standard virtualenvwrapper-win doesn't work in gitbash and it's useful to not have to switch between consoles so I generally install both.
Normally you simply need to open your .bashrc file in your home directory and type something akin to the following:
export WORKON_HOME=$HOME/Envs/
source Path/To/Python/Scripts/virtualenvwrapper.sh
In this case, however, this produced an error complaining that it reached EOL (end of line) while scanning the string literal. It showed the offending line and it was trying to combine the gitbash $HOME variable (with forward slashes) with the windows environment variable (with the backslashes).
How can I fix it so that it's not combining the environment variables?
The first solution is to manually force the script to find the right path by opening virtualenvwrapper.sh and editing line 126:
"$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write('/path/to/your/envs/folder')"
The underlying cause, however, occurs if you try to set an environment variable in windows for WORKON_HOME. If you simply want to share the Envs folder in your home directory, delete the WORKON_HOME environment variable you created in windows and the issue should go away.
If you want it in a completely different place, then use the absolute path (no environment variables such as %USERPROFILE%) in the windows environment variable and it should work.

The term 'go' is not recognized as the name of a cmdlet, function, script file, or operable program

After running...
go run main.go
I get this error
go : The term 'go' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
SOLVED: Go to visual studio code (assuming this is installed) ctrl + shift + p to open command window type
Go: current GOPATH
this should give you a path create a system environment variable named GOPATH and add that path into that variable.
Make sure the system environment variables are set to:
GOPATH is set (in my case) to C:\Users[username]\go
GOROOT is set to C:\go\
IDE is Visual Studio Code.
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
write the code to the terminal and run it. Eazy way to solve the problem.
I had same issue. Then found the below solution on the book "Learning Go" of O'REILLY.
If you are on a Unix-like system using bash, add the following lines to your .profile.
(If you are using zsh, add these lines to .zshrc instead):
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
You’ll need to source $HOME/.profile to make these changes take effect in your cur‐
rent terminal window.
On Windows, run the following commands at the command prompt:
setx GOPATH %USERPROFILE%\go
setx path "%path%;%USERPROFILE%\bin"
After running these commands, you must close your current command prompt and
open a new one for these changes to take effect.
A couple of solutions:
Run refreshenv to refresh the PATH environment variable in the current terminal session.
PS C:\> refreshenv
Refreshing environment variables from the registry for powershell.exe. Please wait...
Finished
PS C:\> go version
go version go1.18.4 windows/amd64
Open a new terminal window and try again.
Restart PC and try again.
I was facing similar issues for commands installed via pip, I had to add the full path to Scripts folder to the PATH variable
C:\Users\username\.pyenv\pyenv-win\versions\3.x.y\Scripts
For go too I believe something similar is to be done.

sqlite from command prompt- not recognized command

I am trying to run sqlite from the command prompt.
So I have this downloaded sqlite-shell-win32-x86-3071100.zip from this website http://www.sqlite.org/download.html
Now there is a set up.exe from which v can run sqlite commands.
When I say
C:\Users\..>'sqlite3' is not recognized as an internal or external com
''sqlite3'' is not recognized as an internal or external command,
operable program or batch file.
Any hints.
Thank you
Sun
From your windows command prompt, you can start sqlite3 either with:
cd c:\Stuff
sqlite3.exe
or with:
c:\Stuff\sqlite3.exe
Either way, I assume from your comment that sqlite3.exe is in c:\Stuff.
As Michael mentioned, you can also add the path of the directory containing sqlite3.exe to your PATH. Fro a quick search I found this guide: http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx
I assume that you already have sqlite in your system path since the instructions on how to do this are clear.
The likely problem is that you have created a folder called sql3 and have put the three executable files in a folder within that folder.
Check that all three executable files are within the file itself.
Go to an environment variable and add new environment variable C:\sqlite as I have saved the sqlite3 files under sqlite folder of C drive. It worked for me
It maybe possible that when u have extracted files from the downloaded zip folder,2 folders are created of the same name one inside the other. So in the cmd prompt u have to enter that folder 2 times by using .
E.g-C:....\sqlite-tools-win32-x86-3330000\sqlite-tools-win32-x86-3330000
and then use sqlite3
If your sqlite3.exe is in C:\Stuff, you can check really quick to see if it's in your PATH.
echo %PATH% will give you your full path. If you don't see ;C:\Stuff there (probably near the end), that's why windows can't find sqlite3.exe.
If you don't see it, run:
setx path "%PATH%;C:\Stuff"
That should be problem solved. Open a new command prompt (it only updates PATHS when the terminal opens), run echo %PATH% and you should now see ;C:\Stuff at the end.
Congrats. sqlite should work in the terminal moving forward.

Resources