Cannot add Pipenv to the path variable whilst following Python Walkthrough Virtual Environments with Pipenv

HI

I have got stuck whilst following Python Walkthrough Virtual Environments with Pipenv when I try to add Pipenv to the path variable I got a message similar to this " ```
E325: ATTENTION
Found a swap file by the name

now when I try to run the command vi ~/.bash_profile all I get is …

added by Anaconda3 2019.10 installer

>>> conda init >>>

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

__conda_setup="$(CONDA_REPORT_ERRORS=false ‘/opt/anaconda3/bin/conda’ shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval “$__conda_setup”
else
if [ -f “/opt/anaconda3/etc/profile.d/conda.sh” ]; then

. “/opt/anaconda3/etc/profile.d/conda.sh” # commented out by conda initialize

    CONDA_CHANGEPS1=false conda activate base
else
    \export PATH="/opt/anaconda3/bin:$PATH"
fi

fi
unset __conda_setup

<<< conda init <<<

>>> conda initialize >>>

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

__conda_setup="$(’/Users/phillipworrall/opt/anaconda3/bin/conda’ ‘shell.bash’ ‘hook’ 2> /dev/null)"
if [ $? -eq 0 ]; then
“~/.bash_profile” 32L, 1108B

Please if can anyone advise me how to fix this issue and add Pipenv to the path variable so I can move on I would really appreciate it.
Thank in advance any advice.

A swap file suggests that file is still open somewhere (normally a buffer in a different window or something). It might be worth quickly backing up the file beforehand but if it’s not open elsewhere you can probably just delete the swap file.

Swap files are like temporary backups (similar to an autosave/backup feature in other text editors) which record recent changes without altering the original file. They’re of more benefit to you if say you had a system crash whilst editing a file before you had a chance to save it, the swap file would likely be able to restore at least some of your work. Sometimes closing terminal windows before saving will do the same thing where the swap file is kept just in case it was an accidental termination of that process. You can check the swap file if you like (if you were doing some interesting editing) but chances are you don’t need it.

That may be a somewhat dated video. Unless you’re familiar with vi you might have an easier time with a regular text editor but you should be careful not to save the file in a rich text format or otherwise (plaintext all the way). An editor like nano can be a more user friendly command line option to those unfamiliar with vi even if it’s a lot less powerful.

As an aside if you’re already using conda you may well be able to get away with either using conda to install packages (and forgoing pipenv enitrely), or, installing pipenv into a conda environment e.g. conda install pipenv and relying on conda to keep pipenv in the PATH rather then editing your bash initialisers. If that was all technical blather to you then feel free to ignore it :slightly_smiling_face:.

Thank you for your quick reply. Its definitely beyond my technical Knowledge :joy: but your explanation has help me understand more what’s the problem is. I will try to continue and deal any potential problems it may cause as I get to them.:joy:

Hey all, I’m having this same issue, when I tried to resolve it I got the following message. I’d really like to figure this out so I can move on and this is very confusing and somewhat daunting in its terminology.

E325: ATTENTION
Found a swap file by the name "~/.bash_profile.swp"
          owned by: SWP   dated: Fri Oct 08 18:18:08 2021
         file name: ~SWP/.bash_profile
          modified: YES
         user name: SWP  host name: terra.local
        process ID: 62546
While opening file "/Users/SWP/.bash_profile"
             dated: Sun Aug 08 15:19:21 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/SWP/.bash_profile"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/Users/SWP/.bash_profile.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:

The swap file here is closer to an auto-save feature. If you were working and the program crashed or was accidentally killed you can potentially recover at least some of your work without a full save. If you know there’s nothing important you can just remove the swap file.

If you’re uncomfortable with the vi program (even the newer vim whilst a great editor has a learning curve) then just use a normal text editor. Just make sure you save as plain text and not rich text.

1 Like

Thank you! This is helpful.

1 Like