Python脚本在PyCharm中运行,但在命令提示符中不运行。

huangapple go评论77阅读模式
英文:

Python script running in pycharm but not in cmd

问题

我在PyCharm中使用Python 3.9版本,脚本可以正常运行,但在cmd中输入python时,它会打开Microsoft Store,显示Python 3.10页面。我需要为cmd授予某种对Python的权限吗?如何操作?

我在网上搜索过,但找不到在不重新下载的情况下使cmd运行Python的方法。

编辑:我想要将cmd用作终端,并能够通过它运行脚本。为了在cmd中使用Python终端,我输入python,但cmd找不到它。这是Python的位置/路径:
C:\Users\ofira\AppData\Local\Programs\Python\Python39\python.exe

英文:

I use Pycharm with python version 3.9 and scripts run just fine,
but when I write python in cmd, it opens Microsoft Store on the page of Python3.10.
Do I need to give cmd some kind of premission to python? How do I do that?

I searched online, but I couldn't find a way to make cmd run python without downloading it again.

edit: I want to use cmd as a terminal and to be able to run scripts through it.
In order to use cmd as python terminal I write python but cmd can't find it.
This is the location/path of python:
C:\Users\ofira\AppData\Local\Programs\Python\Python39\python.exe

答案1

得分: 1

The solution is easy. When the Microsoft Store opens, type "python3.9" in the search tab. Download it, and everything will work like a charm. Downloading it from the store will automatically add the path to the system environment variable.

英文:

The solution is easy. When the microsoft store open's type python3.9 in the search tab. Download it and everything will work like a charm. Downloading it form the store will automatically add the path in the system environment variable.

答案2

得分: 1

I can't write a comment because my reputation is still low, but I was wondering if you were using Pycharm with an interpreter bundled with something like Anaconda (I did and I got the same problem as yours).

If this is the case, I solved it downloading the latest version of python from python.org (like this one) and proceeding with the installation.
You should be able to type python on your prompt and run the interpreter with no effort.
Also, you can choose this new interpreter on Pycharm as well (just go on the lower right corner of the IDE and select it).

Python脚本在PyCharm中运行,但在命令提示符中不运行。

英文:

I can't write a comment because my reputation is still low, but I was wondering if you were using Pycharm with an interpreter bundled with something like Anaconda (I did and I got the same problem as yours).

If this is the case, I solved it downloading the latest version of python from python.org (like this one) and proceeding with the installation.
You should be able to type python on your prompt and run the interpreter with no effort.
Also, you can choose this new interpreter on Pycharm as well (just go on the lower right corner of the IDE and select it).

Python脚本在PyCharm中运行,但在命令提示符中不运行。

huangapple
  • 本文由 发表于 2023年4月11日 16:47:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75984001.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定