--- 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 ""