PredictionIO: Pio command not found after install - bash

I am guessing that somehow PredictionIO didn't setup the path variables properly.
I used method 2 to install PredictionIO from this link here: PredictionIO
Everything installed correctly but when I typed in pio it says command not found. This is what I see:
When I try to start pio from finder I get this:
Kind of lost, what am I doing wrong here?

The solution is to edit your PATH environment variable. You can do it directly in the shell:
$ export PATH=/Users/yourname/PredictionIO/bin:$PATH
However it will be set only as long as the session lasts. To make it permanent, you have to edit your bash profile file. I don't know how it is called on MacOS. On my Ubuntu, it is the .profile file. It is usually .profile, or .bash_profile or something like that.
$PATH is probably set in this file, so find where and edit.
My .profile file has a part in it that reads:
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:/opt/java/jdk1.8.0_45/bin:$PATH"
fi
I would change it to (even though it looks weird because it mixes your MacOS path and my Ubuntu ones):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:/opt/java/jdk1.8.0_45/bin:/Users/yourname/PredictionIO/bin:$PATH"
fi

To get this working I simply did the following, this is for Mac Yosemite users.
$ PATH=$PATH:/Users/yourname/PredictionIO/bin; export PATH
Assuming you installed PredictionIO in that specific directory
Sidenote: I really don't like that there is so much cynicism to beginner's / semi-beginner's in certain areas it really makes me question StackOverFlow.

pio uses its own python version, using your system's python can cause problems, you can define an alias in .zshrc file
alias pio='~/.platformio/penv/bin/python3 ~/.platformio/penv/bin/pio'

Related

source /.bash_profile command not working

I am trying to refresh my aliases on my Mac (OS Catalina 10.15.6) after defining new aliases in my .bash_profile file with the command:
source ~/.bash_profile
But terminal keeps giving this error message:-bash: s: command not found
This is confusing because for the longest time this command worked. I even had it included in my .bash_profile file as an alias, where it worked fine.
I'm aware the problem could have to do it with an error in my PATH but I've never made any edits to my PATH so have no idea what the issue could be?
Thanks in advance.
My first instinct would be to check both ~/.bashrc, and /etc/bashrc if it exists. That is where I customarily define aliases, and it looks to me as though a bad alias may be your problem.
I'm not saying it was the one you made, although it might be. Just go through your rc and profile files and look for any aliases which might in any way clash with source.
I suspect the source command is working just fine and the problem is a bad line in the ~/.bash_profile itself that looks like it's trying to run a command named s. I would look in there for the problem.
It might help to run it with xtrace on via bash -x ~/.bash_profile – running it in a separate process like that won't have any of the presumably-desired side effects of sourceing it in your current shell, but you can see what it's trying to do so that you can fix it.
(You can also just set -x before the source and get both xtrace and running in the current shell; just be sure to set +x afterwards or your shell session will be full of debug output.)

How do programs add to $PATH variable with using .bash_profile?

How do some programs seem to add to the $PATH variable without using a .bash_profile file? What are the advantages to these approaches of adding to $PATH variable, but not using a .bash_profile file?
For my mac
echo $PATH returns
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin
which java returns
/usr/bin/java
which tex returns
/Library/TeX/texbin/tex
How is Java available in the terminal without being in the $PATH variable? (This is an example of something running in the terminal without being in the $PATH variable.)
How did TeX add to the PATH variable without using a .bash_profile file?
What added Library/Apple/usr/bin to the PATH variable? Wikipedia says that only the first three are defaults: /bin, /usr/bin, and /usr/local/bin.
Note: Other StackOverflow posts helped users create a .bash_profile file (a file that doesn't exist by default on a Mac) to run programs such as android and adb when they received -bash: android: command not found
My question is about how the terminal works (like how java is running without being on $PATH) and how other programs (like TeX) added to $PATH without using a file like .bash_profile.
I am running macOS 10.15.5, confirmed that I do not have a .bash_profile file, do have homebrew installed (not sure if that affects anything) and when I open a terminal, it says "The default interactive shell is now zsh." (I think I installed zsh after reading a different StackOverflow a few weeks back.

Command not found and ImportError in Python for OSX

I have OSX El Captain with installed Python3.5 and Python2.7.
I have a folder with my python script and functions which I already added to the environment variable PATH and somehow[*] also to sys.path:
Project_folder/
- Python/
-- __init__.py
-- batchProc.py (written in Python 3.4)
-- (other python files)
I set my PATH with a .bash_profile file:
PATH=“/Users/Robyc/Project_folder/Python:${PATH}”
export PATH
And the folder it's there:
echo $PATH
“/Users/Robyc/Project_Folder/Python:/Library/Frameworks/Python.framework/Versions/3.5/bin:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin”
My sys.path variable
['/Applications/PyCharm CE.app/Contents/helpers/pydev', '/Applications/PyCharm CE.app/Contents/helpers/pydev', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages', '/Users/Robyc/Project_Folder/Python', '/Users/Robyc/Project_Folder/']
I have two problems which I have the feeling that are linked to each other.
if I type bacthProc.py in the terminal I get Command not found. I need to go to ~/Project_folder/Python
if I run ~/Project_folder/Python/batchProc.py the code starts but I get ImportError: No module named Python.
I really don't understand what's wrong with my configuration.
[*] my ~/Project_folder was already there before, but I don't remember how I added it...
My PYTHONPATH is empty. I now used a pth file as suggested in the
documentation to add my ~/Project_folder/Python folder to the
sys.path, i.e. I created the following file:
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/svn_code.pth
which contains:
/Users/Robyc/Project_folder/Python/
For the sake of completeness I share the solution to the problem.
The problem was, as expected, in the PATH variable:
the text editor (TextEdit.app) I used to modify the .bash_profile modified the quotation marks ("...") in a way not correctly recognized by the shell.
This can be actually seen in the path I posted in the question above: the quotation marks shouldn't appear when doing echo $PATH in the terminal.
As a result the PATH variable was not properly set. That's why it wasn't possible to call python anymore.
Solution: open the bash_profile with nano and modify the quotation marks...
and never use again TextEdit to modify the bash_profile

Add virtualenv name to prompt when using pew

I am using pew to manage virtual environments on macOS El Capitan. I would like to get some indication of the virtualenv I am in once I activate one. According to the docs, this behavior should be available out of the box, but if it is not, that you can configure it by adding source $(pew shell_config) to your .bashrc/.bash_profile. I have added this, but it has no affect.
To create a minimal example, I have removed everything from my .bash_profile except for source $(pew shell_config). When I run the pew workon command, my prompt does change, but it simply changes to bash-3.2$, with no indication of the virtual environment.
How can I update my .bash_profile so that pew workon will cause the name of the virtual environment to be displayed in the prompt?
It is my understanding that the prompt that is setup when you switch to a virtualenv is set in shell_config/init.bash. In my case, this file looks like this:
source "$( dirname "${BASH_SOURCE[0]}" )"/complete.bash
PS1="\[\033[01;34m\]\$(basename '$VIRTUAL_ENV')\[\e[0m\]$PS1"
It looks like this should give me the behavior that I want, but it does not seem to be working, and I am not sure why.
Make a .bashrc in your ~ directory and paste in "source $(pew shell_config)"
I had this issue as well and discovered that pew looks for .bashrc, not .bash_profile.
On Ubuntu 20 paste this to the end of .bashrc
# Pew
source "$(~/.local/bin/pew shell_config)"
If I understand correctly, the problem lies in quoting:
PS1="\[\033[01;34m\]\$(basename '$VIRTUAL_ENV')\[\e[0m\]$PS1"
will expand $VIRTUAL_ENV only when it is called the first time and will define a prompt which is unresponsive to subsequent changes of $VIRTUAL_ENV. Try this:
PS1='\[\e[01;34m\]$(basename "$VIRTUAL_ENV")\[\e[0m\]'"$PS1"

In Mac OSX 10.5, it can't find my Terminal commands sudo, find, etc

I don't know what has happened, but in my Terminal on Mac OSX 10.5 it can no longer find my sudo command, or find command, etc. They are there because if I put /usr/bin/sudo or /usr/bin/find it works fine...
My .bash_login file looks like this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
My .bash_profile file looks like this:
export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.5/site-packages/django_trunk/django/bin:/usr/local/mysql/bin:/usr/bin/sudo$PATH"
I'll say now, I don't really know what I'm doing with the Terminal. I'm just a beginner to it all, and I must of done something for the environment variables (is that what they're called?) to be lost. I presumed I'd just have to make sure the /usr/bin/ path is in my bash files, but they are, and it doesn't seem to work. Please help!
Also, when I do use the /usr/bin/find command, it says "Permission denied" to me, even though I am logged into Mac OSX as the System Administrator account. I don't understand.
Any help would be grand. Thank you - James
It looks like both of your PATH exports are malformed:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
The end bit there won't work. It should be:
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:$PATH
Notice the colon before '$PATH'? It's important ;)
Also, the double quotes are not necessary.
If this doesn't work, we will need more information. It is possible that something else is modifying your path even after your shell configurations are loaded.
Can you post the results of:
$ echo $PATH
Configuration files are not always a good indication of the current environment variables, since they are modified by many programs and files, all across your system. To see all of your environment variables, you can run:
$ env
This should fix the problem completely and permanently.
first, export environment paths by using below command in the terminal.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in
now you have the commands you want. (eg. try ls. You'll see the command is working). But this is only for the current session. If you close the terminal and open a new one, you will have the previous issue. To make this change permanent, use below command,
go to home directory
cd ~
open .bash_profile file in nano / vim (I'm using nano here)
nano .bash_profile
This will open up nano editor. In a new line, paste the following;
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH
press 'control'+'o' to save (WriteOut) and 'control'+'x' to exit nano.
All done ! Now try the commands.
Check out --- http://www.sweeting.org/mark/blog/2008/05/26/mac-os-x-tip-setting-path-environment-variables
I went trough the same issue and here is how I solved it.
First of all I reverted the file to its original doing this way
/usr/bin/nano ~/.bash_profile
In my case I was not able to make work any command alias. Even vi or vim didnt work without specifying the full path of that command.
If nano is not installed just replace nano in the command by the editor installed
After that just restart the computer. In my case as I said bellow I could not use any command. When trying to do /usr/bin/source ~/.bash_profile
that command failed. So I had to restart the OS and it worked

Resources