Repository: conan-io/conan
Issue: [bug] Indirect python_requires with version range from cache not found

### Environment details

* Operating System+version: Linux Ubuntu 22.04
* Conan version: 2.0.4
* Python version: 3.10.6

A python_requires package with a version range fails to be found in the local cache (even though a package matching the version range exists) when indirectly required through another package (via normal "requires"). 

Same scenario with a fixed version in the python_requires works.

### Steps to reproduce

Create a trivial package to serve as a python_requires:
```
$ mkdir pr
$ cd pr
$ conan new basic
```
Edit `conanfile.py`. Set package name to "pr". Create package in cache:
```
$ conan create .
```
Create a second package that uses the first as python_requires:
```
$ cd ..
$ mkdir use_pr
$ cd use_pr
$ conan new basic
```
Edit `conanfile.py`. Set package name to "use_pr". Add a line to the class header:
```
    python_requires = "pr/[>0]"
```
(Actually any version range, that includes the version of the "pr" package, will do.)
Create the package in cache:
```
$ conan create .
```
Package will be created without a problem (i. e. the pr/1.0 package will be found and used from cache).
Now create a third basic conan package:
```
$ cd ..
$ mkdir use_use_pr
$ cd use_use_pr
$ conan new basic
```
Edit `conanfile.py`. Set package name to e. g. `use_use_pr`. Add `use_pr/1.0` as normal requirement:
```
    def requirements(self):
        self.requires( "use_pr/1.0")
```
Try to create the package:
```
$ conan create .
```
Package creation will fail, because `pr`-package cannot be found, even though it is in the cache.

### Logs

```
$ conan create .
======== Exporting recipe to the cache ========
use_use_pr/1.0: Exporting package recipe: /home/user/tmp/20230424-conan2-bug-version_range_in_python_requires_when_in_local_cache/use_use_pr-package/conanfile.py
use_use_pr/1.0: Copied 1 '.py' file: conanfile.py
use_use_pr/1.0: Exported to cache folder: /home/user/.conan2/p/use_uc889bfa0cf41d/e
use_use_pr/1.0: Exported: use_use_pr/1.0#b1b720ecaeac4d8f07cde7a0c6369d75 (2023-04-24 18:05:46 UTC)

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=RelWithDebInfo
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux

Profile build:
[settings]
arch=x86_64
build_type=RelWithDebInfo
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux


======== Computing dependency graph ========
pr/[>0]: Not found in local cache, looking in remotes...
pr/[>0]: Checking remote: conan-rme
Graph root
    cli
Requirements
    use_use_pr/1.0#b1b720ecaeac4d8f07cde7a0c6369d75 - Cache
*********************************************************
Recipe 'use_pr/1.0' seems broken.
It is possible that this recipe is not Conan 2.0 ready
If the recipe comes from ConanCenter check: https://conan.io/cci-v2.html
If it is your recipe, check if it is updated to 2.0
*********************************************************

ERROR: Package 'use_pr/1.0' not resolved: use_pr/1.0: Cannot load recipe.
Error loading conanfile at '/home/user/.conan2/p/use_p9732bd97ea5f3/e/conanfile.py': Cannot resolve python_requires 'pr/[>0]': Unable to find 'pr/[>0]' in remotes.
```

Changed files:
conans/client/graph/python_requires.py, conans/test/integration/py_requires/python_requires_test.py

diff --git a/conans/client/graph/python_requires.py b/conans/client/graph/python_requires.py
index 47ee58d9e..814c91e56 100644
--- a/conans/client/graph/python_requires.py
+++ b/conans/client/graph/python_requires.py
@@ -101,8 +101,8 @@ class PyRequireLoader(object):
                                  "Please use version ranges instead")
         if graph_lock:
             graph_lock.resolve_locked_pyrequires(requirement)
-        else:
-            self._range_resolver.resolve(requirement, "py_require", remotes, update)
+        # If the lock hasn't resolved the range, and it hasn't failed (it is partial), resolve it
+        self._range_resolver.resolve(requirement, "py_require", remotes, update)
         ref = requirement.ref
         return ref
 
diff --git a/conans/test/integration/py_requires/python_requires_test.py b/conans/test/integration/py_requires/python_requires_test.py
index 55404c3ab..39cee22c2 100644
--- a/conans/test/integration/py_requires/python_requires_test.py
+++ b/conans/test/integration/py_requires/python_requires_test.py
@@ -1164,3 +1164,20 @@ def test_multi_top_missing_from_remote():
     assert "dep/1.0@user/testing: Downloaded recipe revision" in tc.out
     assert "base/1.1@user/testing: Not found in local cache, looking in remotes..." in tc.out
     assert "base/1.1@user/testing: Downloaded recipe revision" in tc.out
+
+
+def test_transitive_range_not_found_in_cache():
+    """
+    https://github.com/conan-io/conan/issues/13761
+    """
+    c = TestClient()
+    c.save({"conanfile.py": GenConanfile("pr", "1.0")})
+    c.run("create .")
+
+    c.save({"conanfile.py": GenConanfile("dep", "1.0").with_python_requires("pr/[>0]")})
+    c.run("create .")
+
+    c.save({"conanfile.py": GenConanfile("pkg", "1.0").with_requires("dep/1.0")})
+    c.run("create . ")
+    c.assert_listed_require({"pr/1.0": "Cache"}, python=True)
+    assert "pr/[>0]: pr/1.0" in c.out