votes up 3

Destination path '%s' already exists

Package:
pipenv
github stars 22232
Exception Class:
Error

Raise code

            # We might be on a case insensitive filesystem,
            # perform the rename anyway.
            os.rename(src, dst)
            return

        real_dst = os.path.join(dst, _basename(src))
        if os.path.exists(real_dst):
            raise Error("Destination path '%s' already exists" % real_dst)
    try:
        os.rename(src, real_dst)
    except OSError:
        if os.path.isdir(src):
            if _destinsrc(src, dst):
                raise Error("Cannot move a directory '%s' into itself '%s'." % (src, dst))
            copytree(src, real_dst, symlinks=True)
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

Ways to fix

votes up 0 votes down

Summary: solution depends on what you want to achieve. If you have files of the same name in both the source

and the destination folders, you can either overwrite the file in the destination with the file from the source

or move the file from the source and rename it so that both files still exist.

Code to reproduce (WRONG):

First, you have to create two files or directories of the same name. For example, i created two python files both

named asd.py, one in .../src directory, and one in .../dst directory.

from pipenv.vendor.distlib._backport import shutil
import os

shutil.move(f"{os.getcwd()}/src/asd.py"f"{os.getcwd()}/dst/")

This code with said files creates the exception.

Solution 1: leave both files, rename the file from src

from pipenv.vendor.distlib._backport import shutil
import os

shutil.move(f"{os.getcwd()}/src/asd.py"f"{os.getcwd()}/dst/asd2.py")

Solution 2: overwrite the file from dst with the file from src

from pipenv.vendor.distlib._backport import shutil
import os

shutil.move(f"{os.getcwd()}/src/asd.py"f"{os.getcwd()}/dst/asd.py")

Jun 23, 2021 xubiquitous answer

Add a possible fix

Please authorize to post fix