2

Whenever I try to use Python via the terminal, I get this message:

bash: export: `:/usr/bin': not a valid identifier
a:~$ python
Command 'python' is available in '/usr/bin/python'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
python: command not found

Then I use this command to add the path:

export PATH=$PATH=:/usr/bin

But whenever I run the terminal again I get the same error.

UPDATE The problem was solved after following the instruction here: https://askubuntu.com/a/20955 & here: https://askubuntu.com/questions/786349/bash-export-not-a-valid-identifier.

closed as off-topic by Satō Katsura, sebasth, Shadur, Anthon, Stephen Rauch Oct 8 '17 at 15:46

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Satō Katsura, sebasth, Shadur, Anthon, Stephen Rauch
If this question can be reworded to fit the rules in the help center, please edit the question.

  • I've already verified that it is not there. Then used the suggested command and still that did not work. – user7631183 Oct 8 '17 at 11:07
  • 1
    Start a new terminal (or log out / log in again) to clear the broken PATH from your experiment. Also, how did you "verify" that /usr/bin is not in your default PATH? – Satō Katsura Oct 8 '17 at 11:10
  • Can you run the env | grep 'PATH' command and verify it is correct in there? Also if you would like to persistently add /usr/bin to your path environmental variable you should add that line to your ~/.bash_profile or ~/.profile(unless you are on a mac). – Jesse_b Oct 8 '17 at 11:18
  • can you print the content of your PATH variable with echo $PATH ? – carpinchosaurio Oct 8 '17 at 11:25
  • How exactly do you invoke python? What does type python tell you? – Tom Hale Oct 8 '17 at 11:36
3

Try it like this:

export PATH="$PATH:/usr/bin"
  • That did not work. – user7631183 Oct 8 '17 at 11:04
  • @user7631183 That's an opportunity for you to learn more about it. – Satō Katsura Oct 8 '17 at 11:05
0
export $PATH:/usr/bin

This would give rise to the error message

bash: export: `:/usr/bin': not a valid identifier

But only if $PATH was empty or misspelled.

Likewise,

export $PATH

would also give the same error message if $PATH was :/usr/bin.

But

export PATH=$PATH=:/usr/bin

is perfectly legal, but would distort the last path entry in the old $PATH value by adding a = to the end of it.

The correct line to have is

export PATH="$PATH:/usr/bin"

but it's unlikely that this is needed as /usr/bin is very likely already in the system default path that all users have. It is therefore more likely that you somehow unset or seriously mangle the value of $PATH somewhere in your shell startup files.

Review your .bash_profile and .bashrc files and make sure that the syntax is correct whenever you modify your PATH. Then open a new terminal and test it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.