Every time I open my terminal I get the error below:
Last login: Sun Aug 4 17:23:05 on ttys000
-bash: export: `=\': not a valid identifier
-bash: export: `/
I had the same problem and figured it out from your comments, but thought I would add the reason I caused the error to occur (for other beginners).
I had opened and edited .bash_profile using the open command in Terminal, which opened it in Text Editor. I typed in an addition to .bash_profile and it used improper quote characters. I opened .bash_profile in Atom and fixed up the error. I also associated the file with Atom for future editing.
You cannot put spaces around the =
sign when you do:
export foo=bar
Remove the spaces you have and you should be good to go.
If you type:
export foo = bar
the shell will interpret that as a request to export three names: foo
, =
and bar
. =
isn't a valid variable name, so the command fails. The variable name, equals sign and it's value must not be separated by spaces for them to be processed as a simultaneous assignment and export.
Try to surround the path with quotes, and remove the spaces
export PYTHONPATH="/home/user/my_project":$PYTHONPATH
And don't forget to preserve previous content suffixing by :$PYTHONPATH (which is the value of the variable)
Execute the following command to check everything is configured correctly:
echo $PYTHONPATH
First of all go to the /home directorty then open invisible shell script with some text editor, ~/.bash_profile (macOS) or ~/.bashrc (linux)
go to the bottom, you would see something like this,
export LD_LIBRARY_PATH = /usr/local/lib
change this like that( remove blank point around the =
),
export LD_LIBRARY_PATH=/usr/local/lib
it should be useful.
I faced the same error and did some research to only see that there could be different scenarios to this error. Let me share my findings.
Scenario 1: There cannot be spaces beside the =
(equals) sign
$ export TEMP_ENV = example-value
-bash: export: `=': not a valid identifier
// this is the answer to the question
$ export TEMP_ENV =example-value
-bash: export: `=example-value': not a valid identifier
$ export TEMP_ENV= example-value
-bash: export: `example-value': not a valid identifier
Scenario 2: Object value assignment should not have spaces besides quotes
$ export TEMP_ENV={ "key" : "json example" }
-bash: export: `:': not a valid identifier
-bash: export: `json example': not a valid identifier
-bash: export: `}': not a valid identifier
Scenario 3: List value assignment should not have spaces between values
$ export TEMP_ENV=[1,2 ,3 ]
-bash: export: `,3': not a valid identifier
-bash: export: `]': not a valid identifier
I'm sharing these, because I was stuck for a couple of hours trying to figure out a workaround. Hopefully, it will help someone in need.