How can I correct my export PATH from Pipenv video?

Hello- I am new to programming and was working on the Learn Python 3 course, Modules section, Learn Python: Pipenv video. I encountered a problem when trying to change my export PATH. I’m not sure what I did incorrectly, but I am unable to access pipenv and when I open my Terminal, I get the following message:

-bash: dirname: command not found
-bash: dirname: command not found
-bash: dirname: command not found
-bash: dirname: command not found
-bash: export: =': not a valid identifier -bash: export: /Users/jeremy/.local/bin:/Users/jeremy/opt/anaconda3/bin:/bin:/condabin:/Users/jeremy/opt/anaconda3/lib/python3.7/bin:PATH’: not a valid identifier

Any help would be great! Thanks

Hi!

What exactly did you type?

To check if your export is working you can try typing something like

>>> export TESTING=hello
>>> echo $TESTING
hello
1 Like

Hi! thanks for your help- i was able to return “hello” with this command, so that worked.

I think that I initially created the issue when i input spaces before and after the ‘=’ in the export PATH command from the video instructions. But then I messed around with it, trying different paths/directories, so I’m not sure how to fix it now.

You can always edit your bash profile (check which file this is depending in your OS) and source it if you just want to export a PATH command.

Thanks- I tried editing my bash_profile (I’m not sure if I’m doing this correctly or just screwing it up more). I now get the error message:

-bash: /Users/jeremy/.bash_profile: line 16: syntax error: unexpected end of file

When I input vim ~/.bash_profile, this is what comes up:

>>> conda initialize >>>

!! Contents within this block are managed by ‘conda init’ !!

__conda_setup="('/Users/jeremy/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ ? -eq 0 ]; then
eval “$__conda_setup”
else
if [ -f “/Users/jeremy/opt/anaconda3/etc/profile.d/conda.sh” ]; then
. “/Users/jeremy/opt/anaconda3/etc/profile.d/conda.sh”
else
export PATH="/Users/jeremy/opt/anaconda3/bin"

unset __conda_setup

<<< conda initialize <<<

export PATH="/Users/jeremy/.local/bin"
~
~
~
~
~
~
~
“~/.bash_profile” 15L, 524C

Did you source the file afterwards?

I’m not sure- how do i do that?

If it’s bash then source /Users/jeremy/.bash_profile is suitable (double check that file path I just copy/pasted your earlier comment).

I’m also a little confused by those export lines. Normally it’d append to your path e.g. export PATH="mynewcondapath:$PATH".

If you do mess with your conda initialisation then you can run conda init --reverse bash to remove the changes conda made to your bash profile and then conda init bash would implement those changes again.

If you are using conda I’m not sure you really need pipenv anyway. Conda has it’s own tools for managing packages and environments.

Thanks so much- I apologize for the novice questions…I am completely new to this. I am able to access the source /Users/jeremy/.bash_profile in finder and edit this file as needed.

I’m not sure about the export lines. I wish that I could just do what you said about conda…but I;'m getting “-bash: conda: command not found”

If there’s something wrong with the bash profile then then conda isn’t being added to your path so you can’t run the conda commands which would be kind of amusing if it wasn’t so annoying. Sorry about that.

I think it’s probably worthwhile removing all the lines conda has added to your .bash_profile with whatever text editor you like since something there seems to be causing problems. This would be all the text between these two lines (and those lines too)-

# >>> conda initialize >>>
# <<< conda initialize <<<

The following is an attempt to try and sort this out but only run things that you’re comfortable with-

From your message above it looks like the basic bash script for conda environment variable loading is located at the following path /Users/jeremy/opt/anaconda3/etc/profile.d/conda.sh.

Edit: Between these two tasks you should probably close and reopen your terminal program.

Once you’ve cleared the .bash_profile then try running
source /Users/jeremy/opt/anaconda3/etc/profile.d/conda.sh which should add conda environment variables to your current shell environment.

This should allow you to run conda commands in your current shell. Then run conda init bash to get conda to add it’s initialisation scripts to your bash_profile. You can either close and re-open your terminal and you should then be able to use conda automatically in the future (it will be sourced automatically for every new shell you open).

THANK YOU SO MUCH! I think that it’s fixed…I really appreciate it! You really helped me, this is great. Thanks again.

1 Like