Setting PYTHONPATH on ubuntu fails with 'not a valid identifier' - bash

I am trying to set the Pythonpath on a Ubuntu server without luck.
export PYTHONPATH=$PYTHONPATH:/home/ubuntu/canonicaliser_api
This executes without any errors, however when I want to double check the variable.
export $PYTHONPATH
I get this:
-bash: export: `:/home/ubuntu/canonicaliser_api': not a valid identifier
I can't find anything on google. What is causing this?

The error shown is because you are exporting the value of the shell variable PYTHONPATH which is the path that you specified. Do this instead:
export PYTHONPATH
which tells the shell to export the variable named PYTHONPATH, not its value.
If you simply want to see the value of the variable use
echo $PYTHONPATH
instead of export.

Related

Difference between using JAVA_HOME=... and export JAVA_HOME=$(...)

Up until now I've been setting environmental variables using something like:
JAVA_HOME=...
From this https://xenovation.com/blog/development/java/how-to-set-java-home, I can set it using:
export JAVA_HOME=$(/usr/libexec/java_home)
Could someone explain:
Why echo $JAVA_HOME shows /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
I understand that export JAVA_HOME=... sets an environment variable. What does adding $(...) do?
Would export JAVA_HOME=(/usr/libexec/java_home) be the same thing as export JAVA_HOME=/usr/libexec/java_home?
Thank you!
1- /usr/libexec/java_home is an executable that can give you proper value for JAVA_HOME, it also can be used by arguments. for example /usr/libexec/java_home -v '1.7*' will give you sutiable value for JAVA_HOME in order to use Java 7. $(/usr/libexec/java_home) will give you path to JAVA_HOME which in your case will be /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home.
2- $(...) is for command substitution. for example:
a=$(echo foo) # results a="foo"
3- they're not the same in concept! export JAVA_HOME=(/usr/libexec/java_home) will assign an array to JAVA_HOME but export JAVA_HOME=/usr/libexec/java_home ill assign an string path to it. if you echo $JAVA_HOME it will show the first element of array which in your case because you have only one element, it will result into the same thing. It means export JAVA_HOME=(/usr/libexec/java_home) and export JAVA_HOME=/usr/libexec/java_home will be the same.
NOTE: /usr/libexec/java_home is only a binary file which points to real JAVA_HOME. you must execute it with export JAVA_HOME=$(/usr/libexec/java_home) to get true result!

Log: "bash: export: "PATH.": not a valid identifier" when opening terminal on Ubuntu

Whenever I open a terminal, a message appear on top of it saying what I wrote in the title.
I think I messed up with the /etc/profile file when trying to get maven work.
I read some infos on exporting variables, but couldn't find my error, since I followed a guide that worked fine for other people.
The profile file I mentioned has these lines at bottom:
JAVA_HOME=/usr/local/java/jdk1.8.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jre1.8.0
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Setting $JAVA_HOME let me use properly Maven, but creates this annoying message. Can you help me?
As others mentioned in the comments, you are trying to export PATH. instead of PATH somewhere. You might want to check /etc/profile, ~/.bashrc and ~/.bash_profilefiles and try to find this invalid export.
The source you provided is technically ok and you don't need to add any $ signs. Your PATH will contain $HOME/bin value twice though. You might want to change it to look like this:
export JAVA_HOME=/usr/local/java/jdk1.8.0
export JRE_HOME=/usr/local/java/jre1.8.0
export PATH="$PATH:$HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin"

Unable to open bash profile on OSX

I am unable to open bash profile. I had set the Java and Android path but suddenly it is opening. But when I run echo $PATH it is displaying the paths correctly. Now I need to add path to bash profile.
Could anyone please help me?
Your $PATH is wrong :
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin:/Users/qsgte‌​chnologies/Library/Android/sdk/platform-tools:/Users/qsgtechnologies/Library/Andr‌​oid/sdk/tools
This doesn't use standard default path, and, unless this is totally intentional, I recommend you not to do this.
You've got to fix it running this (note /bin:/usr/bin:):
export PATH=/bin:/usr/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin:/Users/qsgte‌​chnologies/Library/Android/sdk/platform-tools:/Users/qsgtechnologies/Library/Andr‌​oid/sdk/tools:
The next time, be sure to use this syntax:
export PATH=$PATH/YourNewPath:
Since you removed /bin:/usr/bin: you where unable to change your bash profile because bash wasn't able to locate your executables.
Fitting your needs, here's your current bash_profile:
export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/qsgtechnologies/Library/Android/sdk
export PATH=$JAVA_HOME/bin:/usr/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
Change it to (note that YourNewEntry is a placeholder for the value you need)
export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/qsgtechnologies/Library/Android/sdk
export PATH=$JAVA_HOME/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:/YourNewEntry
Then apply your changes:
source ~/.bash_profile

zsh error: export:54: not valid in this context:

While messing around with zsh today and getting something configured properly for ruby, I got the following error.
/Users/secallahan/.zshrc:export:54: not valid in this context: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin
Here is my .zshrc (around line 54, where the error occurs) file that I edited.
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
....
....
# User configuration
export $PATH=/Users/secallahan/.rvm/gems/ruby-2.1.1/bin:/Users/secallahan/.rvm/gems/ruby-2.1.1#global/bin:/Users/secallahan/.rvm/rubies/ruby-2.1.1/bin:/Users/secallahan/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin
# export MANPATH="/usr/local/man:$MANPATH"
This was the only way I was able to make it. So then I opened a new shell and did ruby -v and got ruby2.1.1 as the current version.
Any help would be very much appreciated.
When defining or exporting a variable, you should not use $:
export PATH=/Users...
Otherwise, the current value of PATH will be substituted into the export statement.
This can also be caused by using pasted incorrect double quotes for your value
To fix it delete your double quotes and type them in terminal
For example:
export CPPFLAGS=“-I/opt/homebrew/opt/openssl#1.1/include -I/opt/homebrew/opt/zlib/include”
is wrong and needs to be:
export CPPFLAGS="-I/opt/homebrew/opt/openssl#1.1/include -I/opt/homebrew/opt/zlib/include"
You left out the double quotes too.
This was my case, I had to change the syntax from
export PATH=/usr/local/opt/node#12/bin/ to
export PATH="/usr/local/opt/node#12/bin:$PATH"

TERM environment variable not set on mac

I keep on getting the "TERM environment variable not set." error when I work with svn commands on my Mac terminal.
I thought I had set up my profile by doing:
export SVN_EDITOR=/usr/bin/nano
export EDITOR=/usr/bin/nano
in .profile and .bash_profile, reset the terminal and it still gives me that error.
Any help?
Add this to your profile:
export TERM=xterm-color

Resources