Python PyCharm 不检测解释器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32832062/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 12:21:16  来源:igfitidea点击:

PyCharm doesn't detect interpreter

pythonpycharminterpreterpython-3.5

提问by Asier R.

I'm new to programming and just started a course on Python. I want to use PyCharm, so I downloaded and intalled it (v. 4.5, community edition). I had previously installed Python 3.5 64-bit from python.org (I'm using Windows 10).

我是编程新手,刚刚开始学习 Python 课程。我想使用 PyCharm,所以我下载并安装了它(v. 4.5,社区版)。我之前从 python.org 安装了 Python 3.5 64 位(我使用的是 Windows 10)。

To start using PyCharm, I need a project interpreter, which I can select in the settings. As far as I'm concerned, the interpreter is "py.exe", but when I select it, I get this error message: "The selected file is not a valid home for Python SDK". I also tried to use every file whose name contained "python" or "py", and failed.

要开始使用 PyCharm,我需要一个项目解释器,我可以在设置中选择它。就我而言,解释器是“py.exe”,但是当我选择它时,我收到此错误消息:“所选文件不是 Python SDK 的有效主页”。我还尝试使用名称包含“python”或“py”的每个文件,但失败了。

On every website and video I see, they select a file called "python.exe", but they're using Python 3.4 or a previous version. I checked that PyCharm supports 3.5 ("Initial support for Python 3.5").

在我看到的每个网站和视频上,他们都选择了一个名为“python.exe”的文件,但他们使用的是 Python 3.4 或以前的版本。我检查了 PyCharm 是否支持 3.5(“对 Python 3.5 的初始支持”)。

Is there anything I'm doing wrong? What should I do to be able to use PyCharm?

有什么我做错了吗?我应该怎么做才能使用 PyCharm?

All replies are appreciated. Thanks in advance.

感谢所有回复。提前致谢。

回答by xponent

When creating a project in PyCharm, if the interpret is not already selected, in the drop down menu under the projects "Location:", you can click the gear-looking icon to the right of the interpreter option, and click "Add Local"; then select the file location of the python.exe file that you have installed. It will probably be C:\Python35\Python.exe

在PyCharm中创建项目时,如果还没有选择interpreter,在项目“Location:”下的下拉菜单中,可以点击interpreter选项右侧的齿轮图标,点击“Add Local” ; 然后选择您已安装的 python.exe 文件的文件位置。它可能是 C:\Python35\Python.exe

回答by Ben Sharman

I have had the exact same problem and was unable to find the solution until just now. Hopefully this works for anyone that was struggling with it.

我遇到了完全相同的问题,直到现在才找到解决方案。希望这适用于任何正在为此苦苦挣扎的人。

I went to the location of the Python 3.5 (32-Bit) in my C: Drive which it turns out is just a shortcut to the actual Python application, right click on it and select Open file location which should direct you to the application version of python - simply called 'python'. This is the .exe file that PyCharm was looking for to use as the interpreter.

我转到了 C: Drive 中 Python 3.5(32 位)的位置,结果证明它只是实际 Python 应用程序的快捷方式,右键单击它并选择“打开文件位置”,它将引导您进入应用程序版本蟒蛇 - 简称为“蟒蛇”。这是 PyCharm 正在寻找用作解释器的 .exe 文件。

Now go to the configure interpreter menu in Pycharm and type in the file location of the actual python application. To get to mine I had to go to AppData/Local/Programs/Python/Python35-32. Click on the python.exe file and it should work.

现在转到 Pycharm 中的配置解释器菜单并输入实际 Python 应用程序的文件位置。为了找到我的,我必须去 AppData/Local/Programs/Python/Python35-32。单击 python.exe 文件,它应该可以工作。

This is my first post here so if its formatted incorrectly or doesn't use the conventional terms - sorry. Let me know if the solution worked for anyone else with the problem or if I fluked it.

这是我在这里的第一篇文章,所以如果它的格式不正确或不使用传统术语 - 抱歉。让我知道该解决方案是否适用于有问题的其他人,或者我是否失败了。

回答by Anmol G

I faced a Similar issue and was not able to find Pythoninterpreteranywhere on the system.

我遇到了类似的问题,无法Pythoninterpreter在系统上找到任何地方。

The problem with it was that python was installed directly with default settings and there was no exefound in

它的问题是python是用默认设置直接安装的,exe

C:\Python35\ 

and to solve this i tried uninstallingand reinstallingwith custom settings and selecting allow for all users as well which did the trick and path was set correctly to

而要解决这个我想uninstallingreinstalling自定义设置,并选择允许所有用户以及其中的伎俩和路径是否正确设置

C:\Python35\python.exe.

After whichPycharmwas able to detect the interpreter on this path.

之后Pycharm能够检测到这条路径上的解释器。

回答by Haris Ghauri

If you kept the default settings while installing python, Your project interpreter for PyCharm will be:

如果您在安装 python 时保留默认设置,您的 PyCharm 项目解释器将是:

C:\Users\yourUserName\AppData\Local\Programs\Python\Python36\python.exe

C:\Users\yourUserName\AppData\Local\Programs\Python\Python36\python.exe

Chose the above location as your project interpreter inside PyCharm.

选择上述位置作为 PyCharm 中的项目解释器。

Depending on which python version you have, it could be either Python36\python.exe or Python35\python.exe.

根据您使用的 Python 版本,它可以是 Python36\python.exe 或 Python35\python.exe。

回答by Waseem A

PyCharm project interpreter problem Resolved
I installed anaconda python distribution (Anaconda3-5.0.1-Windows-x86_64.exe)from the anaconda website. https://anaconda.org/anaconda/python
What it actually did was it re-installed my Python3.6.3(pertinent to mention I have windows10, with pyCharm community & python 3.5 already but with the interpreter problem and while installing anaconda I chose the following settings and disabled my antivirus before my anaconda installation):

PyCharm 项目解释器问题已解决
我从 anaconda 网站安装了 anaconda python 发行版(Anaconda3-5.0.1-Windows-x86_64.exe)https://anaconda.org/anaconda/python
它实际做的是重新安装了我的 Python3.6.3(相关地提到我有 windows10,pyCharm 社区和 python 3.5 已经但有解释器问题,在安装 anaconda 时我选择了以下设置并在安装 anaconda 之前禁用了我的防病毒软件):

  1. selecting allow for all users
  2. installation path was set correctly and (stored safely for future)
  3. restart my Computer after installation.(not essential-but I did)
  4. opened Anaconda & Jet brian pycharm
  5. selected new project in PyCharm screen shot of my New project default Python interpreterlocation = C:\Users\Skboy\PycharmProjects\daniInterpreter = C:\Users\Skboy\AppData\Local\Programs\Python\Python36-32\python.exe
  1. 选择允许所有用户
  2. 安装路径设置正确并且(安全存储以备将来使用)
  3. 安装后重新启动我的电脑。(不是必需的 - 但我做到了)
  4. 打开 Anaconda & Jet brian pycharm
  5. 我的新项目默认 Python 解释器的PyCharm屏幕截图中选择了新项目 location = C:\Users\Skboy\PycharmProjects\daniInterpreter = C:\Users\Skboy\AppData\Local\Programs\Python\Python36-32\python.exe

Wow! my pyCharm started working for me,

哇!我的 pyCharm 开始为我工作,

Resolution: Python6.3 re-installation with proper custom setting

解决方案:使用正确的自定义设置重新安装 Python6.3

make a python test test1.py program file to print "hello python test world"

制作一个python test test1.py程序文件打印“hello python test world”

Run

now my Python Interpreter(automatically -by default select) Python 3.6.3
edit configuration & check for interpreter

现在我的 Python 解释器(自动 - 默认选择)Python 3.6.3
编辑配置并检查解释器

(C:\Users\user1\AppData\Local\Programs\Python\Python36-32\python.exe)

(C:\Users\user1\AppData\Local\Programs\Python\Python36-32\python.exe)

Run
success test Run
worth to mention Anaconda Jupyter is a web based can also be used in case novice user are still having problems

运行
成功测试 运行
值得一提 Anaconda Jupyter 是一个基于 web 的也可以在新手用户仍然遇到问题的情况下使用

回答by DonkeyKong

file > new project settings > project Interpreter > click in the drop down and select 'show all' > click the '+' button >

文件>新项目设置>项目解释器>单击下拉菜单并选择“全部显示”>单击“+”按钮>

Now, in the Virtualenv Environment tab under the New environment radio button, check the path in the 'Base interpreter:' field. For me, mine was set to an invalid path. Once I had corrected the path to point to python.exe I recreated my new project and PyCharm built the virtualenv.

现在,在 New environment 单选按钮下的 Virtualenv Environment 选项卡中,检查“B​​ase interpreter:”字段中的路径。对我来说,我的设置为无效路径。一旦我更正了指​​向 python.exe 的路径,我就重新创建了我的新项目,PyCharm 构建了 virtualenv。

For me there was a bit more too.... When creating the new project I expanded the drop down and had to verify the directory where the venv directory was being created. Once I had corrected the path here I had to click around a bit to get it to let me create the project.

对我来说还有更多.... 在创建新项目时,我展开了下拉菜单,并且必须验证创建 venv 目录的目录。一旦我更正了这里的路径,我必须点击一下才能让它让我创建项目。

I'm going to chaulk this up to a bug. I'm using Community edition.

我要把这归结为一个错误。我正在使用社区版。

回答by ciornav

For me the following solution it worked:

对我来说,以下解决方案有效:

My configuration: Pycharm Community edition 2019.1.1 Anaconda distribution with python 3.7. Interpreter in standard location.

我的配置:Pycharm Community edition 2019.1.1 Anaconda distribution with python 3.7。标准位置的翻译。

Problem: Pycharm was not able to find python interpreter after reinstallation of anaconda distribution.

问题:重新安装anaconda发行版后,Pycharm无法找到python解释器。

Solution: - Make sure you run pycharm as admin (right click and run as admin). This was actually the critical step. - Create new project (or open an existing one) - Depending on the choice choose interpter or go to file > settings > project interpreter > choose small gear on rights side > add > on base interpreter choose the 3 dots > paste the location of the interpreter in the anaconda distribution.

解决方案: - 确保以管理员身份运行 pycharm(右键单击并以管理员身份运行)。这实际上是关键的一步。- 创建新项目(或打开现有项目) - 根据选择选择解释器或转到文件>设置>项目解释器>选择右侧的小齿轮>添加>在基础解释器上选择3个点>粘贴位置anaconda 发行版中的解释器。

Hope it helped someone. For me the blocking point was that for some reason pycharm was not launching with admin rights.

希望它对某人有所帮助。对我来说,阻塞点是由于某种原因 pycharm 没有以管理员权限启动。

Blockquote

块引用