Python 无法在 Windows 中新安装的 Pycharm 中启动控制台
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29192068/
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
Cannot start a console in newly installed Pycharm in Windows
提问by Youngsup Kim
On Windows 7 machine, Pycharm (community or professional) and Python 3.4 (tried Anaconda 3 as well) were installed newly. There were not problems running Python scripts interactively in main editor. However, when I tried to select View > Tool Windows > Python Console, it generates the following error messages and more. Basically, I couldn't bring up a console window in Pycharm.
在 Windows 7 机器上,新安装了 Pycharm(社区版或专业版)和 Python 3.4(也尝试过 Anaconda 3)。在主编辑器中以交互方式运行 Python 脚本没有问题。但是,当我尝试选择View > Tool Windows > Python Console 时,它会生成以下错误消息等。基本上,我无法在 Pycharm 中调出控制台窗口。
C:\Users\user\Anaconda3\python.exe -u C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevconsole.py 56743 56744
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydev_imports.py", line 21, in <module>
from SimpleXMLRPCServer import SimpleXMLRPCServer
ImportError: No module named 'SimpleXMLRPCServer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevconsole.py", line 20, in <module>
import pydevd_vars
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevd_vars.py", line 9, in <module>
from pydevd_xml import *
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevd_xml.py", line 7, in <module>
from pydev_imports import quote
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydev_imports.py", line 23, in <module>
from xmlrpc.server import SimpleXMLRPCServer
File "C:\Users\user\Anaconda3\lib\xmlrpc\server.py", line 108, in <module>
from http.server import BaseHTTPRequestHandler
File "C:\Users\user\Anaconda3\lib\http\server.py", line 660, in <module>
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
File "C:\Users\user\Anaconda3\lib\http\server.py", line 851, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File "C:\Users\user\Anaconda3\lib\mimetypes.py", line 348, in init
db.read_windows_registry()
File "C:\Users\user\Anaconda3\lib\mimetypes.py", line 255, in read_windows_registry
with _winreg.OpenKey(hkcr, subkeyname) as subkey:
TypeError: OpenKey() argument 2 must be str without null characters or None, not str
Process finished with exit code 1
Couldn't connect to console process.
-----------------these messages were showed up in "Python Console"-------------
-----这些消息显示在“Python 控制台”中------------
回答by wyleu
The configuring of pycharm in the presence of various development configurations is a bit of a black art IMHO. The most effective mechanism I've found for pinning this down is put random strings into the various settings dialogs, Interpreters, consoles, tests , servers and observe the command lines submitted to the interpreter VERY carefully. Hardly a satisfactory approach but it will sort out what is going where and to a certain degree what effects what.
在各种开发配置存在的情况下配置pycharm有点黑,恕我直言。我发现的最有效的机制是将随机字符串放入各种设置对话框、解释器、控制台、测试、服务器中,并非常仔细地观察提交给解释器的命令行。几乎不是一种令人满意的方法,但它会整理出正在发生的事情以及在一定程度上影响什么。
The other think that helps me are screenshots of the settings and testing dialogs of working installations.
另一个认为对我有帮助的是工作安装的设置和测试对话框的屏幕截图。
Again, a bit rough and ready but it has got me up and running again after a long period of successful debugging followed by pycharm amnesia.
再一次,有点粗糙和准备,但经过长时间的成功调试和 pycharm 健忘症后,它让我再次启动并运行。
回答by uday
You need to change your working directory. Go to File->Settings->Build, Execution, Deployment->Console->Python Console
and then change or provide a directory where you have read and write access in the Working directory
box.
您需要更改工作目录。转到File->Settings->Build, Execution, Deployment->Console->Python Console
然后更改或提供您在Working directory
框中具有读写访问权限的目录。
回答by Hymanssn
I had same problem. I reinstalled python and default directories have changed.
我有同样的问题。我重新安装了 python 并且默认目录已更改。
Then I just refreshed interpreter here File->Settings->Build, Execution, Deployment->Console->Python Console
and hereFile->Settings->Project: <YOUR_PROJECT>->Project Interpreter
.
然后我只是在这里File->Settings->Build, Execution, Deployment->Console->Python Console
和这里刷新了解释器File->Settings->Project: <YOUR_PROJECT>->Project Interpreter
。
If you will open new projects interpreter will need choose again (?)
如果您将打开新项目,解释器将需要再次选择 (?)
回答by Olive.b
I got it resolved by setting the interpreter in Preferences and project interpreter.
我通过在首选项和项目解释器中设置解释器来解决它。