Repository: conan-io/conan

Issue:
Error message when no conanfile was found is confusing
When no conanfile is found, a message such as 
```
ERROR: Conanfile not found: D:\Foo\conanfile.txt
```
is displayed. There is no reference to a conanfile.py that was considered (and is also missing).

To help us debug your issue please explain:

- [x] I've read the [CONTRIBUTING guide](https://raw.githubusercontent.com/conan-io/conan/develop/.github/CONTRIBUTING.md).
- [x] I've specified the Conan version, operating system version and any tool that can be relevant.
- [x] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.




Discussion:

Resolving patch:
diff --git a/conans/client/conan_api.py b/conans/client/conan_api.py
--- a/conans/client/conan_api.py
+++ b/conans/client/conan_api.py
@@ -111,25 +111,32 @@ def _get_conanfile_path(path, cwd, py):
     """
     param py= True: Must be .py, False: Must be .txt, None: Try .py, then .txt
     """
+    candidate_paths = list()
     path = _make_abs_path(path, cwd)
 
     if os.path.isdir(path):  # Can be a folder
         if py:
             path = os.path.join(path, "conanfile.py")
+            candidate_paths.append(path)
         elif py is False:
             path = os.path.join(path, "conanfile.txt")
+            candidate_paths.append(path)
         else:
             path_py = os.path.join(path, "conanfile.py")
+            candidate_paths.append(path_py)
             if os.path.exists(path_py):
                 path = path_py
             else:
                 path = os.path.join(path, "conanfile.txt")
+                candidate_paths.append(path)
+    else:
+        candidate_paths.append(path)
 
     if not os.path.isfile(path):  # Must exist
-        raise ConanException("Conanfile not found: %s" % path)
+        raise ConanException("Conanfile not found at %s" % " or ".join(candidate_paths))
 
     if py and not path.endswith(".py"):
-        raise ConanException("A conanfile.py is needed (not valid conanfile.txt)")
+        raise ConanException("A conanfile.py is needed, " + path + " is not acceptable")
 
     return path
 


Test patch:
diff --git a/conans/test/command/package_test.py b/conans/test/command/package_test.py
--- a/conans/test/command/package_test.py
+++ b/conans/test/command/package_test.py
@@ -1,11 +1,11 @@
+import os
 import unittest
 
 from conans import tools
-from conans.test.utils.tools import TestClient
-import os
 from conans.paths import CONANFILE
-from conans.util.files import load, mkdir
 from conans.test.utils.test_files import temp_folder
+from conans.test.utils.tools import TestClient
+from conans.util.files import load, mkdir
 from parameterized import parameterized
 
 
@@ -70,14 +70,16 @@ def package_with_path_errors_test(self):
         error = client.run("package conanfile.txt --build-folder build2 --install-folder build",
                            ignore_error=True)
         self.assertTrue(error)
-        self.assertIn("A conanfile.py is needed (not valid conanfile.txt)", client.out)
+        self.assertIn(
+            "A conanfile.py is needed, %s is not acceptable" % os.path.join(client.current_folder, "conanfile.txt"),
+            client.out)
 
         # Path with wrong conanfile path
         error = client.run("package not_real_dir/conanfile.py --build-folder build2 --install-folder build",
                            ignore_error=True)
         self.assertTrue(error)
-        self.assertIn("Conanfile not found: %s" % os.path.join(client.current_folder, "not_real_dir",
-                                                               "conanfile.py"), client.out)
+        self.assertIn("Conanfile not found at %s" % os.path.join(client.current_folder, "not_real_dir",
+                                                                 "conanfile.py"), client.out)
 
     def package_with_reference_errors_test(self):
         client = TestClient()
diff --git a/conans/test/command/source_test.py b/conans/test/command/source_test.py
--- a/conans/test/command/source_test.py
+++ b/conans/test/command/source_test.py
@@ -93,14 +93,16 @@ def source_with_path_errors_test(self):
         # Path with conanfile.txt
         error = client.run("source conanfile.txt --install-folder subdir", ignore_error=True)
         self.assertTrue(error)
-        self.assertIn("A conanfile.py is needed (not valid conanfile.txt)", client.out)
+        self.assertIn(
+            "A conanfile.py is needed, %s is not acceptable" % os.path.join(client.current_folder, "conanfile.txt"),
+            client.out)
 
         # Path with wrong conanfile path
         error = client.run("package not_real_dir/conanfile.py --build-folder build2 --install-folder build",
                            ignore_error=True)
         self.assertTrue(error)
-        self.assertIn("Conanfile not found: %s" % os.path.join(client.current_folder, "not_real_dir",
-                                                               "conanfile.py"), client.out)
+        self.assertIn("Conanfile not found at %s" % os.path.join(client.current_folder, "not_real_dir",
+                                                                 "conanfile.py"), client.out)
 
     def source_local_cwd_test(self):
         conanfile = '''
diff --git a/conans/test/command/test_package_test.py b/conans/test/command/test_package_test.py
--- a/conans/test/command/test_package_test.py
+++ b/conans/test/command/test_package_test.py
@@ -109,14 +109,16 @@ def test_with_path_errors_test(self):
         # Path with conanfile.txt
         error = client.run("test conanfile.txt other/0.2@user2/channel2", ignore_error=True)
         self.assertTrue(error)
-        self.assertIn("A conanfile.py is needed (not valid conanfile.txt)", client.out)
+        self.assertIn(
+            "A conanfile.py is needed, %s is not acceptable" % os.path.join(client.current_folder, "conanfile.txt"),
+            client.out)
 
         # Path with wrong conanfile path
         error = client.run("test not_real_dir/conanfile.py other/0.2@user2/channel2",
                            ignore_error=True)
         self.assertTrue(error)
-        self.assertIn("Conanfile not found: %s" % os.path.join(client.current_folder, "not_real_dir",
-                                                               "conanfile.py"), client.out)
+        self.assertIn("Conanfile not found at %s" % os.path.join(client.current_folder, "not_real_dir",
+                                                                 "conanfile.py"), client.out)
 
     def build_folder_handling_test(self):
         test_conanfile = '''