cygwin bash.rc to run two separate programs - bash

I'm trying to run Python and Julia from the Cygwin command line, but I've installed Python and Julia to two separate directories. I can run Python from Cygwin with
$ python testfile.py
because I added export PATH=/cygdrive/c/anaconda2:$PATH to bash.rc so that I can run Python. However, my Julia installation sits in a different directory. Can I add something like export PATH2=/cygdrive/c/Julia-0.5.1/bin:$PATH2 to run Julia files from command line with
$ julia testfile.jl
or what should I do?

Why not add both paths in the bash.rc?
export PATH=/cygdrive/c/anaconda2:/cygdrive/c/Julia-0.5.1/bin:$PATH

Related

Bash script fails with Python3.8: command not found

I'm new to bash and scripting in general.
In short, I'm to run a particular build and one of the tasks fails. This is the first time I'm running this build so I was expecting all sort of issues.
The script starts with: #!/usr/bin/env bash
And fails with : python3.8: command not found at line X, which is: python3.8 -m venv $ENV_PATH
I'm using zsh, brew installed.
Which python:
➜ ~ which python3
/usr/bin/python3
➜ ~ which python
/usr/bin/python
Exact version:
➜ ~ python3 --version
Python 3.8.9
I also edited the .zshrc file and added an alias:
alias python3.8='python3'
And it opens up the Python3.8 terminal when I type 'python3.8' now.
What could be the source of this issue? I know I might have messed up a lot of things. I'm also confused with all of these Bash profiles. Using zsh while it loads the default bash? where does it take it's commands from?
Appreciate any help...
You need to source your PATH: Before you call python, you should put:
PATH+=:/usr/bin
The path in the shell script is different from your system path, so you need to source your system path within the shell script.

How to remotely execute a bash script in pycharm?

I own the licensed version of Pycharm. I have installed BashSupport plugin as well.
However, I am not sure what steps are required to remotely test and execute a bash script on RHEL server.
I am able to configure a remote interpreter but the interpreter path is /usr/bin/python.
In my logic you need to change interpreter path to /bin/bash instead of /usr/bin/python or i don't understand what you are trying to do..
I've met the save problem today.
If I use the default pycharm bash configuration, I'll get the following error:
C:\windows\system32\bash.exe C:/git/NewProject/run.sh
/bin/bash: C:/git/NewProject/run.sh: No such file or directory
Process finished with exit code 127
So, I change the default Windows Script path to Linux absolute Script path as following:
Run successfully.
You gotta check the path on server, If there is alias set, You can check alias
$ which python
$ whence python (Some version)
$ ls -l `which python`

How do Python commands, and any other commands, get automatically set up in terminal?

I was trying to set up a platform that used pip and I realized I had to install it using 'sudo easy_install'. I think easy_install is a python-enabled command that was set up in terminal after I installed Python.
How does it work that after you install something like Python, a command like easy_install is automatically activated with-in terminal that can call what easy_install does? Is there some sort of active list of commands that is updated for all terminal executions by programs that are installed?
Thanks.
All the places that the terminal will search for programs are in the PATH variable. To see which directories are in your path variable you can run the following in your terminal: echo $PATH. Note that paths are colon separated on most UNIX-based systems. As such, all programs contained in directories that are in the PATH variable are ones that can be run without specifying a relative/absolute path to them.

New to OSX and commands are never found so I 'export' them. Is there a way to fix it for good?

I'm new to bash and my Mac (about a week) and only 3 months into programming. I've been running into this problem where it ends up being something in my bash profile.
Like changing environment variables in my python so commands like
PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH”
export DATABASE_URL=“postgresql://localhost/CHEESE”
export APP_SETTINGS=“config.DevelopmentConfig"
or to get my Postgres in python to work I have to do this
export PATH=/Applications/Postgres.app/Contents/Versions/9.3/bin/:$PATH
recently I just installed virtualenvwrapper and had to do a sudo pip install virtualenvwrapper and running the code in bash would not find it unless I did this
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
So I did some research and I THINK I can permanatly add them to my 'bash profile'. If this is the case I have 2 questions.
Is there a way I can avoid having to manually add the exports in the first place. So I can have the commands working right after installing
How do I add them to my profile. I opened my .bash_profile.swp and it looked intimidating so I didn't touch it because I thought I'd break it. I'm not sure why I had a random pathing for my psycopg2 at the end of the line either( seen in the second link)
http://imgur.com/jedEOn9
http://imgur.com/CYsgVmx
You are correct. Adding these to your .bash_profile will set the environment variables every time you start up your shell. However, as explained here, it is better to put them in your .bashrc and then source that from your .bash_profile. For example,
# put this in your .bashrc
PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
export DATABASE_URL="postgresql://localhost/CHEESE"
export APP_SETTINGS="config.DevelopmentConfig"
# etc...
# then put this in your .bash_profile
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
This ensures the variables are properly set no matter how you start your shell. The .swp file you are seeing is created by Vim. Just ignore it.
However, there is a better way. The easiest and cleanest way to install software on your computer is with a package manager, which will automatically set the paths for you (among other things). For Mac, I recommend using Homebrew. Once you install it, you can do things like
$ brew install ruby
$ ruby blah blah blah # ruby gets put in the PATH for you!
For python, the standard package manager is pip, which you are already using. However, a word of advice: sudo pip installs packages for the python 2 that comes as part of OS X, which from personal experience I recommend not doing. Instead, install python 2 with Homebrew, and then use the pip (and the python) that comes with that.

Use the python interpreter packaged with py2exe

I have a python script I want to distribute to Windows, where people might not have python installed. So I use py2exe. The problem is in the script I run other python scripts by using subprocess, which requires python interpreter as the program to execute. As I don't have python interpreter installed on Windows, is there any way I could ignore the interpreter and work around the problem? Is there any way I could call the python interpreter pakcaged by py2exe?
It's probably more simple than you think: Instead of starting sub-processes, use the built-in eval() command to execute the scripts.
[EDIT] To redirect stdio, replace sys.stdout/sys.stderr with buffers or something else that supports "write()".
To restore the original values, the sys module offers __stdout__, etc.
[EDIT2] I haven't tried this but it might work: Add "python.exe" to the set of files which py2exe creates.
From the main code, copy all files that py2exe created + the python.exe into a temporary directory. Then add all your scripts.
Now start the new python interpreter with a small script that adds the temp folder and library.zip to the sys.path
Note: Python doesn't have to be "installed" like a Windows application. In fact, you can simply copy all the files to a new place. As long as the search path is correct, this works.

Resources