src/eric7/Project/Project.py

branch
eric7
changeset 10593
b7ebfc2e47d4
parent 10569
1f2bde269aa2
child 10595
59579e8aff98
child 10596
ea35c92a3c7c
diff -r 8edb63666f73 -r b7ebfc2e47d4 src/eric7/Project/Project.py
--- a/src/eric7/Project/Project.py	Mon Feb 19 14:33:08 2024 +0100
+++ b/src/eric7/Project/Project.py	Mon Feb 19 19:17:04 2024 +0100
@@ -7107,19 +7107,21 @@
         @return path of the embedded virtual environment (empty if not found)
         @rtype str
         """
-        with os.scandir(self.getProjectPath()) as ppathDirEntriesIterator:
-            for dirEntry in ppathDirEntriesIterator:
-                # potential venv directory; check for 'pyvenv.cfg'
-                if dirEntry.is_dir() and os.path.exists(
-                    os.path.join(dirEntry.path, "pyvenv.cfg")
-                ):
-                    return dirEntry.path
-
-        # check for some common names in case 'pyvenv.cfg' is missing
-        for venvPathName in (".venv", "venv", ".env", "env"):
-            venvPath = os.path.join(self.getProjectPath(), venvPathName)
-            if os.path.isdir(venvPath):
-                return venvPath
+        ppath = self.getProjectPath()
+        if ppath and os.path.exists(ppath):
+            with os.scandir(self.getProjectPath()) as ppathDirEntriesIterator:
+                for dirEntry in ppathDirEntriesIterator:
+                    # potential venv directory; check for 'pyvenv.cfg'
+                    if dirEntry.is_dir() and os.path.exists(
+                        os.path.join(dirEntry.path, "pyvenv.cfg")
+                    ):
+                        return dirEntry.path
+
+            # check for some common names in case 'pyvenv.cfg' is missing
+            for venvPathName in (".venv", "venv", ".env", "env"):
+                venvPath = os.path.join(self.getProjectPath(), venvPathName)
+                if os.path.isdir(venvPath):
+                    return venvPath
 
         return ""
 

eric ide

mercurial