i would like to have a separate window open for the ouput of the console, like when i run my program without pycharm instead of the output going in the "run" tab of pycharm.
thanks in advance
First of all you didn't provide the information, I would have loved to see which OS you use or what are your preferences for visualizing your output which really needed to solve your problem so I'll answer your question generally.
If you are using windows you can use the command prompt also called the cmd to run your python file, using a simple WinKey + R and then writing cmd which will open a simple Command Prompt, then you will need to navigate to your python file path with the command cd which you can read about in the internet and then run python file_name or python3 file_name depending on what you have, this will give you your code output.
Using linux dist it will be very similar to the windows one pressing ALT+T will open the terminal for you which is like the twin brother for your cmd and then you'll need to follow the cd step and further in my first note.
Both ways will give you to run your code and will show you the output of your code without using pycharm.
Hope I helped :)
Related
I'm using VS Code for a Python project using a virtualenv. I switched my deafult terminal from powershell to cmd as VS Code was not happy executing powershell scripts.
Now when I open a terminal in my project it opens cmd (as desired), but automatically tries tor run .../Scripts/Activate.ps1, which it doesn't like. I want it to run .../Scripts/Activate.bat as we are in cmd. Runnning it manually for now, but would be nice if I didn't have to.
No doubt there is a setting somewhere to change this, but I cannot find it. Any ideas?
This is a problem related to the Python extension, it should be fixed in the last update.
You can get some information from here.
My terminal is running python 2 so when I run my python file the program fails.
So basically I am new to programming and trying to create a small python script to help me auto create folders. I also want to give the script to colleges so that they can use it on their systems too.
I know that I can run my file in terminal by using "python3 myfile.py" and it will work, but that's too much off a mission to do for my colleges and as my colleges are not familiar with code or terminal for that matter, I wanted to create an executable file so that they just click to open type a few answers to the promoted question and boom folders created.
This is where I run into a problem, I have "#!/usr/bin/env python3" at the top of my file but when I run the script IDLE opens up and it just shows the code I have written but doesn't seem to run the actual script I wrote. Am I doing something wrong?
I also then though perhaps I could just use the terminal to run the file as it is now executable, so I go into terminal and enter "myfile.py" and the program runs but in python 2 so my script fails as it is in python3. So another question would be is there a way to code into my python file, when running this file make sure you use python3? as I would want this to work on all colleges system without them having to write out anything in terminal?
Sorry for the long explanation but any advice would be greatly appreciated.
Thank you in advance
When you are on windows you can just create a .bat file where you write: python3 myfile.py in it.
Both files have to be in the same directory.
If you want to have a .exe you can also use py2exe.
You could also try just #!/usr/bin/python3 without env.
More here.
When I code in shell for practicing and when I am done I close it, when I reopen it I cannot code in it again I have to open a new one !
How can I code in the same old one of shell ??
python command doesn't preserve your work
You can try installing IPython, Jupyter, or use a proper IDE for practicing
The python shell isn't meant to write full programs. It's nice for testing small pieces of code, but if you'd like to continue previous code, use the Python IDLE that comes with the standard download installation (in python shell -> File -> New File). This will require you to save the file to run the code. However, this IDE is not very user friendly. As user cricket_007 has mentioned, there are other IDE's that have autocomplete and other helpful tools.
Start using a terminal multiplexer like tmux or screen and launch python under it. My favourite is tmux. Your python session would persist till you kill the tmux session or till logout / reboot
It seems that the spyder has removed python console, but I got a program can only be run by python console, what can I do? or is there any thing I am wrong?
I got some codes from github, and it needs ADB driver for Android, after I installed ADB, I can run the program in cmd using python wechat_jump_auto.py, but cannot run in spyder with ipython.
In Spyder3 installed in Windows OS, we can add the path to adb using Tools --> Current user environment variables....
Here, we can add the path to adb.exe file by appending it to the path variable. Then, we need to restart Spyder3. Then you will be able to directly run your script with access to adb.exe from Spyder3 IPython console or simply by clicking Run button.
Just came across the same problem as you recently.
In fact, it seems that program using ADB tools just cannot run in Spyder even by python console (my Spyder IDE is equipped with both Ipython console and Python console).
One practical way to solve this problem is to run your code in cmd.
Open your cmd window and do something like this:
python "xxx(path)\xxxx.py(file name)"
In my case, it looks like this:
example image
Hit Enter, and hopefully your code will run successfully.
If it still cannot run, maybe you haven't set your environment variables correctly.
Hope this can solve your problem. Good luck :)
I have a little a script containing some "dictionaries".
"Is there any way I can take this script and import it's contents to idle?"* using a command like import.
What want to do then is to edit (or view) these dictionaries "live" in idle.....
Copy paste the script into the shell. Make sure there are no blank lines inside indented blocks or you'll get a SyntaxError.
Yes, import command should work: Just put "import myScript". You can add a path to your script with a line like sys.path.append(r"D:\myPath") before that statement
If you are on Windows right click on the script > Open with > Choose your Idle if it's there if not click on more(not sure what it's named it's the last option) then there should be some more options to open the file if your idle is still not there you can browse your files and go to the folder where your idle is saved and choose the exe to open the script in the Idle
Well I have to confess that I use linux mint, so there's no such thing as idle and that is why I use the terminal (where I type python3) to code instead! To make it clear, what I wanted to do is to take a script which contains a dictionary and some functions and then run it in terminal in order to use those functions there. The import command has nothing to do here!!!The answer is to use the exec commmand!!! Here is a picture:1. My question was not clear......
P.S Mushroommaula answered the question.