python virtualenvwrapper producing an EOL error on install - windows

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.

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?

Windows 7 set environment variable using Cygwin

I'm trying to use Cygwin to run some astrophysics code called FAST through a program called IDL. In order to do this, I need to set environment variables for the installation path of IDL and the directory of IDL. When I go to the system variables tab in the system settings, I name the variable as appropriate and set the value to C:\Program Files\Exelis\IDL85, but I get an error saying that
STUDENT#SES-6TTJK72 /cygdrive/c/Users/Administrator/Downloads/FAST_v1.0/FAST_v1.0/example_phot
$ ../fast
../fast C:\Program Files\Exelis\IDL85 .:+C:\Program Files\Exelis\IDL85/lib
../fast: line 6: C:\Program: command not found
Now this seems to be happening because Cygwin can't read the space in Program Files as space is used to delimit the arguments, but I've tried every solution I can think of to get around this. I've tried Program\ Files, I've tried quotes around the whole thing, etc. I was just wondering if there was some way to set the windows environment variables in Cygwin itself so I can just type the path out in the notation that Cygwin uses and it would be able to understand it for sure. Any help on this would be much appreciated!

Complete Guide for Installing APM on Windows

Currently, I am studying about ReactJS with Atom Editor and I want to try out ATOM REACT PLUGIN. For the installation, it require me to use the command apm install react but the Windows CMD doesn't recognize apm. After searching on the internet, it seems that calling the apm command is simple on Mac but not simple on Windows. Is there a step by step installation guide for apm in Windows?
Install Shell Commands on Mac:
In Windows version, I cannot find it out:
Add it to the system path environment variables.
- `Win + R: then type %localappdata%`
Go to Atom > app-(atom version)> resources > app > apm > bin
Copy the entire path and open the system path environment settings window.
Append to the end and confirm. Restart console(command prompt or gitbash)
This applies to every command line interface, in case you want to know where the executable is located use the where command.
- where apm
- where node
courtesy :- https://github.com/atom/apm/issues/381#issuecomment-126911491
The problem is that the Atom installation did not successfully add the Atom bin folder to the path.
I run into this issue quite a bit, as Windows environment variables are of finite size. On my dev machine, where I typically have many things installed, each install wants to add itself to the path, resulting in a very long PATH variable, which ends up being truncated by the OS, causing lots of headaches.
It can actually break things quite badly for you, if the truncation happens at an unfortunate location.
Here's my solution:
You need to edit and clean up both the User PATH env variable, as well as System one.
I usually would copy them into a text editor (on Win7: Right-click on Computer->Properties->Advanced system settings->Environment Variables->double-click PATH)
then I replace the ';' character with a linebreak char (depending on your editor, it could be something else) for easier editing.
Then I proceed to remove duplicates
Then I remove long paths with environment variables that I previously defined.
For example, there are lots of occurrence of 'C:\Program Files (X86)'.
That's 22 characters for every occurrence.
You can define a system environment variable, say 'PgmX86', then replace every occurrence of the longer string with '%PgmX86%'.
You will save 14 characters for each occurrence.
Similarly, replace occurrences of 'C:\Users\AppData\Local' with %LocalAppData%, which is a predefined variable.
I then restore the ';' characters instead of line breaks, and then paste back into the env variable setting dialog.
Once you go thru this kind of cleanup, don't forget to add %LocalAppData%\atom\bin to your user path.
That should take care of Atom and apm!

attempting to assign alias to path of an exe file in dos shell

I want to set an alias to my installation of firefox so I can easily start a web page, the problem is that I dont want the script to be system dependent.
Namely I want it to be able to run on a linux distribution where the command to start firefox is already mapped to 'firefox' and can easily be run that way through bash, but on my windows machine I cant seem to get it to assign to the same variable.
I saw that I could set it to '%firefox%' via the set command but that's not quite what I want.
I believe creating aliases is possible on a windows environment because the version of svn that I use auto-installed and was able to assign itself to 'svn'. Anyone know what was involved in them being able to get their alias working, or a similar way to alias a command?
If you include your Firefox path in the %PATH% environment variable, you can start FF with "firefox". Under Windows, you should edit the system-wide settings (see this link).
AFAIK, there is nothing similar to aliases under DOS/Windows (except the %firefox% way you mentioned, too). The 'svn' command you talked about most likely is the same thing, a 'svn.exe' and its path included to %PATH%.
This is a bit restrictive, as you can only use the original filename to launch a program, but you can work around this by creating a batch file in the program's path that launches the program, f.e. a FF.BAT that contains "firefox %1".
Alternatively, you can place a batch file in a path that already is in %PATH%, f.e. the Windows directory. That way, you don't have to modify %PATH%.

Resources