{"record":{"id":"e608aa7458c4fb94","repo":"astral-sh/uv","slug":"cannot-run-a-python-module-from-stdin","errorCode":null,"errorMessage":"Cannot run a Python module from stdin","messagePattern":"Cannot run a Python module from stdin","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/uv/src/commands/project/run.rs","lineNumber":1521,"sourceCode":"\n    /// Determine the [`ParsedRunCommand`] for a given set of arguments.\n    pub(crate) fn from_args(\n        command: &ExternalCommand,\n        module: bool,\n        script: bool,\n        gui_script: bool,\n    ) -> anyhow::Result<Self> {\n        let (target, args) = command.split();\n        let Some(target) = target else {\n            return Ok(Self::Ready(RunCommand::Empty));\n        };\n\n        if target.eq_ignore_ascii_case(\"-\") {\n            let mut buf = Vec::with_capacity(1024);\n            std::io::stdin().read_to_end(&mut buf)?;\n\n            return if module {\n                Err(anyhow!(\"Cannot run a Python module from stdin\"))\n            } else if gui_script {\n                Ok(Self::Ready(RunCommand::PythonGuiStdin(buf, args.to_vec())))\n            } else {\n                Ok(Self::Ready(RunCommand::PythonStdin(buf, args.to_vec())))\n            };\n        }\n\n        let target_path = PathBuf::from(target);\n\n        // Determine whether the user provided a remote script.\n        if target_path.starts_with(\"http://\") || target_path.starts_with(\"https://\") {\n            // Only continue if we are absolutely certain no local file exists.\n            //\n            // We don't do this check on Windows since the file path would\n            // be invalid anyway, and thus couldn't refer to a local file.\n            if !cfg!(unix) || matches!(target_path.try_exists(), Ok(false)) {\n                let url = DisplaySafeUrl::parse(&target.to_string_lossy())?;\n                return Ok(Self::PendingRemote(PendingRemoteRunCommand {","sourceCodeStart":1503,"sourceCodeEnd":1539,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv/src/commands/project/run.rs#L1503-L1539","documentation":"Error \"Cannot run a Python module from stdin\" thrown in astral-sh/uv.","triggerScenarios":"Thrown at crates/uv/src/commands/project/run.rs:1521 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}