[Windows] NoPythonVersion: Python interpreter is not found on the system.
See original GitHub issue- I have searched the issue tracker and believe that this is not a duplicate.
Make sure you run commands with -v
flag before pasting the output.
Steps to reproduce
I’m using Windows machine. I installed PDM with pip in Python3.7 version. I run pdm sync
and it returns
Traceback (most recent call last):
File "c:\users\cye1\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\cye1\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\Scripts\pdm.exe\__main__.py", line 7, in <module>
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\core.py", line 233, in main
return Core().main(args)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\core.py", line 168, in main
raise cast(Exception, err).with_traceback(traceback)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\core.py", line 163, in main
f(options.project, options)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\cli\commands\run.py", line 280, in handle
sys.exit(runner.run(options.command, options.args))
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\cli\commands\run.py", line 220, in run
[command] + args, **self.global_options # type: ignore
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\cli\commands\run.py", line 98, in _run_process
project_env = project.environment
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\project\core.py", line 224, in environment
self._environment = self.get_environment()
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\project\core.py", line 219, in get_environment
return Environment(self)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\models\environment.py", line 75, in __init__
self.interpreter: PythonInfo = project.python
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\project\core.py", line 157, in python
self._python = self.resolve_interpreter()
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\project\core.py", line 195, in resolve_interpreter
for py_version in self.find_interpreters():
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\project\core.py", line 610, in find_interpreters
for entry in finder.find_all(*args):
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\findpython\finder.py", line 94, in find_all
matched_python = set(self._find_all_python_versions())
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\findpython\finder.py", line 127, in _find_all_python_versions
yield from provider.find_pythons()
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\findpython\providers\path.py", line 25, in find_pythons
yield from self.find_pythons_from_path(path)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\findpython\providers\base.py", line 50, in <genexpr>
if path_is_python(child)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\findpython\utils.py", line 93, in path_is_python
if not path_is_readable(path) or not path.is_file():
File "c:\users\cye1\anaconda3\lib\pathlib.py", line 1382, in is_file
return S_ISREG(self.stat().st_mode)
File "c:\users\cye1\anaconda3\lib\pathlib.py", line 1178, in stat
return self._accessor.stat(self)
OSError: [WinError 1920] The file cannot be accessed by the system: 'C:\\Users\\cye1\\AppData\\Local\\Microsoft\\WindowsApps\\MicrosoftEdge.exe'
I have no idea why MicrosoftEdge is involved in this scenario. 😂
I figured it could be due to my messy Python environment, so I installed Python3.9 and tried to use pdm use -v C:/Users/cye1/AppData/Local/Programs/Python/Python39/python
to let PDM use the new Python3.9. It shows (see Actual behavior)
Actual behavior
Traceback (most recent call last):
File "c:\users\cye1\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\cye1\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\Scripts\pdm.exe\__main__.py", line 7, in <module>
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\core.py", line 233, in main
return Core().main(args)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\core.py", line 168, in main
raise cast(Exception, err).with_traceback(traceback)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\core.py", line 163, in main
f(options.project, options)
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\cli\commands\use.py", line 30, in handle
project, options.python, options.first, options.ignore_remembered
File "C:\Users\cye1\AppData\Roaming\Python\Python37\site-packages\pdm\cli\actions.py", line 563, in do_use
raise NoPythonVersion("Python interpreter is not found on the system.")
pdm.exceptions.NoPythonVersion: Python interpreter is not found on the system.
Expected behavior
PDM to recognize the Python3.9 interpreter and use it smoothly.
Environment Information
It shows the OSError again when I run pdm info && pdm info --env
# Paste the output of `pdm info && pdm info --env` below:
$ pdm info && pdm info --env
[OSError]: [WinError 1920] The file cannot be accessed by the system: 'C:\\Users\\cye1\\AppData\\Local\\Microsoft\\WindowsApps\\MicrosoftEdge.exe'
Add '-v' to see the detailed traceback
Maybe my PDM is not installed properly? Thanks for your help! 🥰
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
VS Code Python installation and Python Interpreter not ...
Find python at "C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe" · Copy this path · In the file explorer right click "This PC" ...
Read more >Configure a Python interpreter | PyCharm Documentation
Press Ctrl+Alt+S to open the IDE settings and select Project <project name> | Python Interpreter. · Expand the list of the available interpreters ......
Read more >Python is not recognized as an internal or external command
This error appears on Windows operating systems when the location of the Python executable file has not been properly specified in the system...
Read more >Select and install Python interpreters - Visual Studio (Windows)
A complete list of Python interpreters that are supported in Visual Studio with brief instructions on where to find their installers.
Read more >Python 3.x interpreter not found · Issue #1616 - GitHub
I tried setting PYO3_PYTHON=py to see if a generic executable as found on the path could be supplied, so that I don't have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This issue should be fixed in the new release of
findpython
, and those executables will be skipped.For anyone who has the issue as well, I uninstalled and reinstalled PDM using
pip install pdm
.findpython==0.1.3
was installed by default, so the error still happened. I ranpip install update findpython==0.1.4
and it’s fixed.