Cannot start a console in newly installed Pycharm

2019-04-28 04:20发布

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.

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"-------------

4条回答
Bombasti
2楼-- · 2019-04-28 05:05

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.

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.

查看更多
淡お忘
3楼-- · 2019-04-28 05:06

I got it resolved by setting the interpreter in Preferences and project interpreter.

查看更多
Deceive 欺骗
4楼-- · 2019-04-28 05:13

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.

查看更多
我欲成王,谁敢阻挡
5楼-- · 2019-04-28 05:13

I had same problem. I reinstalled python and default directories have changed.

Then I just refreshed interpreter here File->Settings->Build, Execution, Deployment->Console->Python Console and here File->Settings->Project: <YOUR_PROJECT>->Project Interpreter.

If you will open new projects interpreter will need choose again (?)

查看更多
登录 后发表回答