How can I correct my export PATH from Pipenv video?

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

Hi there!! I’m having exactly your same problem and it is very frustrating, I’m also very new with all this and I get stuck very often (but I still try).

How did you finally fix the problem?

I’m also getting the message “-bash: conda: command not found” when I try running “conda init --reverse bash”
After this step, I got confused with the last comment before you fixed it.

It’d be amazing if you can give me a hand!
:slight_smile:

You would only need to run conda init --reverse bash if you were trying to remove conda’s initialisation scripts from that file. It was necessary in this case because the section with the export statement was incorrect (at least I think that was the cause) which led to the issue of export... not a valid identifier.

A short discussion on why...

Getting conda to write to your shell initialisation scripts is a reasonable thing to do though. Unfortunately, if conda is not already added to your PATH in your shell initialisation you cannot use conda based scripts easily.

What you probably need to do is to start at the step of sourcing the backup activation script for conda so that you can use conda commands. After that running conda init bash might be helpful as it’ll add the activations hooks to your shell startup files so that new terminals will automatically have the conda commands available.

The following steps here would depend on your OS and the relevant filepaths so you’ll need to alter these commands a bit. Looking after your shell initialisation scripts in your home directory is up to you, they are designed to be personalised to suit you. As such you should know what they contain and what those commands do; you’ll save yourself some headaches if you learn even a little about them now.

I don’t know for certain as you have very little detail about what is wrong but you’d probably want to start at roughly this step:
source /Users/name/opt/anaconda3/etc/profile.d/conda.sh

If that works correctly, then you can run the initialisation command to add to your shell startup scripts. If you’re on more recent OSX you’d probably be using zsh isntead of bash so adjust the command accordingly-
conda init bash

If that works you should close your open terminal and from then on any new terminals you open should have to conda commands set up automatically.

1 Like

Hey! First of all, thanks for taking your time.

I tried to do what you said in your comment and this what I’m getting on my terminal.

Last login: Fri May 28 17:53:08 on ttys000
-bash: export: =': not a valid identifier -bash: export: /Users/trinidadbosch/Library/Python/3.9/bin:PATH’: not a valid identifier
MacBook-Pro-de-Trinidad:~ trinidadbosch$ source /Users/trinidadbosch/opt/anaconda3/etc/profile.d/conda.sh
MacBook-Pro-de-Trinidad:~ trinidadbosch$ conda init bash
no change /Users/trinidadbosch/opt/anaconda3/condabin/conda
no change /Users/trinidadbosch/opt/anaconda3/bin/conda
no change /Users/trinidadbosch/opt/anaconda3/bin/conda-env
no change /Users/trinidadbosch/opt/anaconda3/bin/activate
no change /Users/trinidadbosch/opt/anaconda3/bin/deactivate
no change /Users/trinidadbosch/opt/anaconda3/etc/profile.d/conda.sh
no change /Users/trinidadbosch/opt/anaconda3/etc/fish/conf.d/conda.fish
no change /Users/trinidadbosch/opt/anaconda3/shell/condabin/Conda.psm1
no change /Users/trinidadbosch/opt/anaconda3/shell/condabin/conda-hook.ps1
no change /Users/trinidadbosch/opt/anaconda3/lib/python3.7/site-packages/xontrib/conda.xsh
no change /Users/trinidadbosch/opt/anaconda3/etc/profile.d/conda.csh
modified /Users/trinidadbosch/.bash_profile

==> For changes to take effect, close and re-open your current shell. <==

MacBook-Pro-de-Trinidad:~ trinidadbosch$

As far as I can see it says “no change” and then when I reopen my terminal the initial message still there.

Last login: Fri May 28 17:57:50 on ttys000

-bash: export: `=’: not a valid identifier

-bash: export: `/Users/trinidadbosch/Library/Python/3.9/bin:PATH’: not a valid identifier

(base) MacBook-Pro-de-Trinidad:~ trinidadbosch$

Also, when I try to source the file I’m a getting this message

MacBook-Pro-de-Trinidad:~ trinidadbosch$ /Users/trinidadbosch/.bash_profile

-bash: /Users/trinidadbosch/.bash_profile: Permission denied

What does “permission denied” means here? I’m not really sure what I’m trying to do by running it thou.

And last (cause this message is getting too long but I’m trying to give you as much detail as I can), if I run vi ~/.bash_profile, this is the message that I get (maybe I should start from here?)

export PATH = “/Users/trinidadbosch/Library/Python/3.9/bin:PATH”

Setting PATH for Python 3.8

The original version is saved in .bash_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"

export PATH

Setting PATH for Python 3.8

The original version is saved in .bash_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"

export PATH

alias python=“python3”

alias pip=“pip3”

Setting PATH for Python 3.9

The original version is saved in .bash_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"

export PATH

>>> conda initialize >>>

I’m not really sure has anything to do with conda. You seem to have a bad line in your initialisation scripts (I’m assuming one of either .bash_profile or .bashrc).

The line containing this text in particular threw the error: Users/trinidadbosch/Library/Python/3.9/bin:PATH

Can you find a line that uses that text? Do you have unusual syntax there? At a guess you’ve probably got a line that looks like-

export = '/Users/trinidadbosch/Library/Python/3.9/bin:PATH'

That should be (no spaces around the = symbol)…

export='/Users/trinidadbosch/Library/Python/3.9/bin:PATH'

I think that would be the most likely cause. Have a look and see if you can fix it.

Be aware that these two options are somewhat conflicting, if you source conda and then add yet another Python distribution to the head of you PATH you’ll probably have some trouble. I’d suggest adding only one of them at any one time, or at the very least append conda after the first one if you intend to use conda’s Python as your main Python distribution. The easiest would be one or the other though.

Ok I will, but first I tried opening again my terminal and running vi ~/.bash_profile and I’m getting this

E325: ATTENTION
Found a swap file by the name “~/.bash_profile.swp”
owned by: trinidadbosch dated: Fri May 28 18:43:56 2021
file name: ~trinidadbosch/.bash_profile
modified: YES
user name: trinidadbosch host name: MacBook-Pro-de-Trinidad.local
process ID: 17552
While opening file “/Users/trinidadbosch/.bash_profile”
dated: Fri May 28 18:25:40 2021

(1) Another program may be editing the same file. If this is the case,
be careful not to end up with two different instances of the same
file when making changes. Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use “:recover” or “vim -r /Users/trinidadbosch/.bash_pr
ofile”
to recover the changes (see “:help recovery”).
If you did this already, delete the swap file “/Users/trinidadbosch/.bash_pr
ofile.swp”
to avoid this message.

Swap file “~/.bash_profile.swp” already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

Any idea if this is because of conda?
I prefer to do step by step and don’t mess it again!!!

I doubt it would be conda, do you have any other terminals or text editors open at this moment?
Namely this one- process ID: 17552

You might want to look into how to manage processes by id on mac if you don’t have any open editors as the most likely situation then would probably be a hung application.

Yep, found it. I pressed “D” to delete it, is that ok?

It’s unlikely to cause any significant problems, the swap file is just a history of unsaved changes that you probably made yourself. If the actual file is still there then it will still be sourced with your new log-in shells, just make sure that file is up to snuff.

It might be worth taking a little time reading into bash environment variables (including PATH) as it’s a fairly straightforward subject and it makes your life easier to see what you actually do when using these commands.

1 Like

100% agree on the reading, any recommendation of a good source?

I think it worked, after I delete it I went back and modified this code

export = ‘/Users/trinidadbosch/Library/Python/3.9/bin:PATH’

By removing the space. After I close the terminal and open it again I’m getting this

Last login: Fri May 28 19:08:18 on ttys000
-bash: dirname: command not found
-bash: dirname: command not found
-bash: dirname: command not found
-bash: dirname: command not found
(base) MacBook-Pro-de-Trinidad:~ trinidadbosch$

Any idea on what -bash: dirname: command not found means and if it is causing any troubles?

Sorry, I hadn’t really read that properly the first time, I was just focused on the error. Yes that’s not ideal, definitely a broken PATH. Your code prevents any expansion of the existing PATH at the minute, you need both parameter expansion for the existing path $PATH instead of just the plain text PATH and the quoting should be weak quoting or less, e.g. "stuff" instead of strong quoting 'stuff' as strong quotes disallow the expansion too.

Probably something like this-
export="/Users/trinidadbosch/Library/Python/3.9/bin:$PATH"

Oh ouch, when I try running the ‘vi’ code it doesn’t work so I can’t modify the whole PATH code (help :cold_sweat:).

Last login: Fri May 28 19:08:18 on ttys000

-bash: dirname: command not found

-bash: dirname: command not found

-bash: dirname: command not found

-bash: dirname: command not found

(base) MacBook-Pro-de-Trinidad:~ trinidadbosch$ vi ~/.bash_profile

-bash: vi: command not found

Maybe just open it with the textedit app or similar GUI tool.

If you know the correct path to vi probably /usr/bin/vi or something you could use that if you really wanted to.

I plugged it on my terminal and I’ve got this

~ VIM - Vi IMproved
~
~ version 8.0.1283
~ by Bram Moolenaar et al.
~ Vim is open source and freely distributable
~
~ Become a registered Vim user!
~ type :help register for information
~
~ type :q to exit
~ type :help or for on-line help
~ type :help version8 for version info
~
~
~

Hey! I was able to open .bash_profile on textedit but I’m not sure what to change to get rid of the “-bash: dirname: command not found”, can you please help me a bit? This is what is in the file

export PATH="/Users/trinidadbosch/Library/Python/3.9/bin:PATH"

Setting PATH for Python 3.8

The original version is saved in .bash_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH

Setting PATH for Python 3.8

The original version is saved in .bash_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH

alias python=“python3”
alias pip=“pip3”

Setting PATH for Python 3.9

The original version is saved in .bash_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
export PATH

>>> conda initialize >>>

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

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

<<< conda initialize <<<

Hey!! I fixed it, I went to your comment in Feb 1st and I followed it and now my terminal is working without any weird message.

THANKS!

2 Likes

Hi mate! Me again hahaha I was working on my terminal and when I type the “ls” I’m getting

-bash: ls: command not found

Any idea on what could be causing this error on my PATH? Here is what it contains.

export PATH="/Users/trinidadbosch/Library/Python/3.9/bin:PATH"

Setting PATH for Python 3.8

The original version is saved in .bash_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH

Setting PATH for Python 3.8

The original version is saved in .bash_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH

alias python=“python3”
alias pip=“pip3”

Setting PATH for Python 3.9

The original version is saved in .bash_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
export PATH

>>> conda initialize >>>

<<< conda initialize <<<