Importing modules in PyQGIS

Try replacing sys.path.insert(0, r'c:\scripts') with sys.path.append(r'c:\scripts') instead and add the required imports in your A.py.


c:\scripts\A.py

from qgis.core import QgsVectorLayer, QgsVectorFileWriter

def create_copy(input,output): 
    layer = QgsVectorLayer(input, "input", "ogr")
    error = QgsVectorFileWriter.writeAsVectorFormat(layer, output, "utf-8", None, "ESRI Shapefile")

c:\scripts\B.py

import sys
sys.path.append(r'c:\scripts')
import A

A.create_copy(r"z:\original.shp", r"z:\copy.shp")