Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
340 views
in Technique[技术] by (71.8m points)

python - How to run a file in IPython console as default instead of terminal?

I started a new project in PyCharm. I have Anaconda 3.6 installed. So, in PyCharm, I selected the Anaconda python.exe as project interpreter.

When I first ran PyCharm, it used the IPython console as "default" console to run my script. Then I restarted my PC and now PyCharm uses the terminal when I run my scripts. Why? I don't want to use the terminal, coming from Anaconda Spyder IDE. I'm used to IPython, I like it and I want to use it.

How can I completely disable the terminal and use only the IPython console?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Short answer:

  1. Go to File > Default settings > Build, Execution, Deployment > Console and select Use Ipython if available
  2. Go to Run > Edit Configurations and select Show command line afterwards

Tip: Run selected parts of your code with ALT + SHIFT + E


The details:

If you've selected Anaconda as the project interpreter, IPython will most likely be the selected console even though it neither looks nor behaves like the IPython console you are used to in Spyder:

enter image description here

Unlike Spyder, PyCharm has no graphical indicator showing that this is an IPython console.

enter image description here

To make sure it's an IPython console and make it behave more or less like the IPython console you are used to from Spyder, you should follow these two steps:

  1. Go to File > Default Settings > Build, Execution, Deployment > Console and make sure to select Use IPython if available. enter image description here

  2. Go to Run > Edit Configurations and select Show command line afterwards enter image description here

Now you can run selected parts of your code with ALT+SHIFT+E more or less exactly like in Spyder.

If this doesn't do the trick, you should check out these other posts on SO:

Interacting with program after execution

Disable ipython console in pycharm


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...