# Buggy code
def pyinstall(source_folder):
    pyinstaller_path = os.path.join(os.getcwd(), "pyinstaller")
    _install_pyintaller(pyinstaller_path)

    for folder in ("conan", "conan_server", "conan_build_info"):
        try:
            shutil.rmtree(os.path.join(pyinstaller_path, folder))
        except Exception as e:
            print("Unable to remove old folder", e)

    conan_path = os.path.join(source_folder, "conans", "conan.py")
    conan_server_path = os.path.join(source_folder, "conans", "conan_server.py")
    conan_build_info_path = os.path.join(source_folder, "conans/build_info/command.py")
    hidden = "--hidden-import=glob"
    if platform.system() != "Windows":
        hidden += " --hidden-import=setuptools.msvc"
    subprocess.call(
        "python pyinstaller.py -y -p %s --console %s %s"
        % (source_folder, conan_path, hidden),
        cwd=pyinstaller_path,
        shell=True,
    )
    _run_bin(pyinstaller_path)

    subprocess.call(
        "python pyinstaller.py -y -p %s --console %s"
        % (source_folder, conan_server_path),
        cwd=pyinstaller_path,
        shell=True,
    )

    subprocess.call(
        "python pyinstaller.py -y -p %s --console %s -n conan_build_info"
        % (source_folder, conan_build_info_path),
        cwd=pyinstaller_path,
        shell=True,
    )

    conan_bin = os.path.join(pyinstaller_path, "conan", "dist", "conan")
    conan_server_folder = os.path.join(
        pyinstaller_path, "conan_server", "dist", "conan_server"
    )

    conan_build_info_folder = os.path.join(
        pyinstaller_path, "conan_build_info", "dist", "conan_build_info"
    )
    dir_util.copy_tree(conan_server_folder, conan_bin)
    dir_util.copy_tree(conan_build_info_folder, conan_bin)
    _run_bin(pyinstaller_path)

    return os.path.abspath(os.path.join(pyinstaller_path, "conan", "dist", "conan"))


# Traceback (ImportError)
~/test $ conan new Hello/0.1 -t
File saved: conanfile.py
File saved: test_package/CMakeLists.txt
File saved: test_package/conanfile.py
File saved: test_package/example.cpp
~/test $ conan create demo/testing
Hello/0.1@demo/testing: Exporting package recipe
Traceback (most recent call last):
File "conan/conans/client/command.py", line 895, in run
File "conan/conans/client/command.py", line 184, in create
File "conan/conans/client/conan_api.py", line 63, in wrapper
File "conan/conans/client/conan_api.py", line 292, in create
File "conan/conans/client/manager.py", line 166, in export
File "conan/conans/client/linter.py", line 21, in conan_linter
File "conan/conans/client/linter.py", line 68, in _lint_py3
File "conan/conans/client/linter.py", line 51, in _runner
File "pylint/lint.py", line 1220, in __init__
File "pylint/lint.py", line 458, in load_default_plugins
File "pylint/lint.py", line 478, in _load_reporter
File "astroid/modutils.py", line 437, in get_module_part
File "astroid/modutils.py", line 338, in file_from_modpath
File "astroid/modutils.py", line 383, in file_info_from_modpath
File "astroid/modutils.py", line 603, in _spec_from_modpath
File "astroid/interpreter/_import/spec.py", line 279, in find_spec
File "astroid/interpreter/_import/spec.py", line 246, in _find_spec_with_path
ImportError: No module named text

ERROR: No module named text

# Fixed code
def pyinstall(source_folder):
    pyinstaller_path = os.path.join(os.getcwd(), "pyinstaller")
    _install_pyintaller(pyinstaller_path)

    for folder in ("conan", "conan_server", "conan_build_info"):
        try:
            shutil.rmtree(os.path.join(pyinstaller_path, folder))
        except Exception as e:
            print("Unable to remove old folder", e)

    conan_path = os.path.join(source_folder, "conans", "conan.py")
    conan_server_path = os.path.join(source_folder, "conans", "conan_server.py")
    conan_build_info_path = os.path.join(source_folder, "conans/build_info/command.py")
    hidden = "--hidden-import=glob --hidden-import=pylint.reporters.text"
    if platform.system() != "Windows":
        hidden += " --hidden-import=setuptools.msvc"
    subprocess.call(
        "python pyinstaller.py -y -p %s --console %s %s"
        % (source_folder, conan_path, hidden),
        cwd=pyinstaller_path,
        shell=True,
    )
    _run_bin(pyinstaller_path)

    subprocess.call(
        "python pyinstaller.py -y -p %s --console %s"
        % (source_folder, conan_server_path),
        cwd=pyinstaller_path,
        shell=True,
    )

    subprocess.call(
        "python pyinstaller.py -y -p %s --console %s -n conan_build_info"
        % (source_folder, conan_build_info_path),
        cwd=pyinstaller_path,
        shell=True,
    )

    conan_bin = os.path.join(pyinstaller_path, "conan", "dist", "conan")
    conan_server_folder = os.path.join(
        pyinstaller_path, "conan_server", "dist", "conan_server"
    )

    conan_build_info_folder = os.path.join(
        pyinstaller_path, "conan_build_info", "dist", "conan_build_info"
    )
    dir_util.copy_tree(conan_server_folder, conan_bin)
    dir_util.copy_tree(conan_build_info_folder, conan_bin)
    _run_bin(pyinstaller_path)

    return os.path.abspath(os.path.join(pyinstaller_path, "conan", "dist", "conan"))