I'm a noob in computer programming, today i installed vscode to learn python, everything was right, i run short and simple lines of code installed some extensions, but i dont know what happened, I'm not sure if i changed some configuration but when i try to run little lines of code (with the button) instead of running it and showing it to me in the "terminal section", it sends me to the "output" section and it just says that the code already run and its done.
Do somebody knows how to solve it please, it really makes me sad that i just ruined this program because its my first day and this already screw it.
As you can see in the picture, i run the code and it shows off something different in the output section, i wrote that but later changed it. It seem like it runs the file but only when i save it. :(
You must save the file to get the new output everytime.
For running code in Terminal with the button -
It looks like you are using Code Runner vscode extension. Which by default uses Output section to show output and cannot take input. You can change this behavior of that extension by pressing ctrl + , and going into vscode settings. Then just search code runner run in terminal You'll see an option to enable Run in Terminal feature turn that on.
So I just created a simple script with selenium that automates the login for my University's portal. The first reaction I got from a friend was: ah nice, you can put that on my pc as well. That would be rather hard as he'd have to install python and run it through an IDE or through his terminal or something like that and the user friendliness wouldn't be optimal.
Is there a way that I could like wrap it in a nicer user interface, maybe create an app or something so that I could just share that program? All they'd have to do is then fill in their login details once and the program then logs them in every time they want. I have no clue what the possibilities for that are, therefore I'm asking this question.
And more in general, how do I get to use my python code outside of my IDE? Thusfar, I've created some small projects and ran them in PyCharm and that's it. Once again, I have no clue what the possibilities are so I also don't really know what I'm asking. If anyone gets what I mean by using my code further than only in my IDE, I'd love to hear your suggestions!
The IDE running you program is the same as you running your program in the console. But if you dont want them to have python installed (and they have windows) you can maybe convert them to exe with py2exe. But if they have linux, they probably have python installed and can run you program with "python script.py". But tell your friends to install python, if they program or not, it will always come in handy
I am unsure of how, (or if you can) incorporate an existing Apple script made in macOS Script Editor into a Python project in PyCharm.
The AppleScript looks in a specific area of an app, and returns how long you've been doing a certain activity based on a set of GUI-based commands. That much is working as expected, but I want to use PyCharm to create an applet that displays said results in the menu bar.
Through a bit of research and asking around, it sounds like Subprocess Management is what I'll need to use, but I'm still new to Python, and don't want to go down that rabbit hole if it isn't what I need, or if there is an easier way.
Here's an example of the AppleScript:
tell application "System Events"
tell process "App that I am using"
set activityState to value of menu button 1 of group 1 of group 4 of toolbar 1 of window of application process "App that I am using" of application "System Events" as list
return activityState as string
end tell
end tell
As of now, I don't have any of the Python scripting done since I'm still unsure if what I want to do can be accomplished.
The Apple Script above is working as expected, other than a repeat forever statement that I have not added yet.
I have PyCharm 2019.1.3 and Python 3.7 installed on my Mac, but haven't attempted to write anything there since I'm new and unsure if this is something that can be done.
I'm trying to learn FreeCAD python scripting. Basically I open the python console and do what I want to do in the GUI and then look into the python console to learn the commands. and then read the API for that specific task to learn the correct form of python commands.
Things were going fine till I got stuck in this weird issue where the program (I.E FreeCAD) does not execute parts of my code. For example in this macro I create three boxes and then fuse two toghther, and it works just fine. But in this one I create 3 boxes, fuse two of them together, and then try to cut the fusion out of the bigger box. and it doesn't work. I even tried including some flags using print("flag"), but it does not execute these commands. If I copy and past the exact commands into the python consol and run it works fine!
so my speculations are:
FreeCAD does something in the GUI which does not report in the python console.
FreeCAD python interpreter does not execute some commands such as print("")
there is something in FreeCAD API which I'm not using correctly
I would appreciate if you could help me know:
if this is a bug in FreeCAD/python or it is intentional
how can I solve the issue so the FreeCAD python interpreter runs my macro/script as I expect?
P.S. I posted the exact same question here in FreeCAD forum.
OK, I figured the problem out. you may see the correct macro here in this Github Gist
explanation: Basically the solution is that when we want to run a Boolean operation on two existing objects we should not change their visibility to false (as the default GUI commands do). If we include those commands then none of the commands after them will be executed.
This may sound strange, but I need a better way to build python scripts than opening a file with nano/vi, change something, quit the editor, and type in python script.py, over and over again.
I need to build the script on a webserver without any gui. Any ideas how can I improve my workflow?
put this line in your .vimrc file:
:map <F2> :w\|!python %<CR>
now hitting <F2> will save and run your python script
You should give the screen utility a look. While it's not an IDE it is some kind of window manager on the terminal -- i.e. you can have multiple windows and switch between them, which makes especially tasks like this much easier.
You can execute shell commands from within vim.
Using emacs with python-mode you can execute the script with C-c C-c
you can try ipython. using its edit command, it will bring up your editor (nano/vim/etc), you write your script, and then on exiting you're returned to the ipython prompt and the script is automatically executed.
When working with Vim on the console, I have found that using "tabs" in Vim, instead of having multiple Vim instances suspended in the background, makes handling multiple files in Vim more efficient. It takes a bit of getting used to, but it works really well.
You could run XVNC over ssh, which is actually passably responsive for doing this sort of thing and gets you a windowing GUI. I've done this quite effectively over really asthmatic Jetstart DSL services in New Zealand (128K up/ 128K down =8^P) and it's certainly responsive enough for gvim and xterm windows. Another option would be screen, which lets you have multiple textual sessions open and switch between them.
There are actually 2 questions. First is polling for a console IDE for python and the second is a better dev/test/deploy workflow.
For while there are many ways you can write python code in the console, I find a combination of screen, vim and python/ipython is the best as they are usually available on most servers. If you are doing long sessions, I find emacs + python-mode typically involves less typing.
For a better workflow, I would suggest setting up a development environment. You can easily setup a Linux VM on your desktop/laptop easily these days - there isn't a excuse not to even if it's for hobby projects. That opens up a much larger selection of IDEs available to you, such as:
GUI versions of VI and friends
Remote file editing with tramp and testing locally with python-mode inside Emacs
http://www.netbeans.org
and of course http://eclipse.org with the PyDev plugin
I would also setup a SCM to keep track of changes so that you do
better QA and use it to deploy tested changes onto the server.
For example I use Mercurial for my pet projects and I simply tag my repo when it's ready and update the production server to the tag when I deploy. On the devbox, I do:
(hack hack hack, test test test)
hg ci -m 'comment'
hg tag
hg push
Then I jump onto the server and do the following when I deploy:
hg update
restart service/webserver as needed
Well, apart from using one of the more capable console editors (Emacs or vi would come to mind), why do you have to edit it on the web server itself? Just edit it remotely if constant FTP/WebDAV transfer would seem to cumbersome.
Emacs has Tramp Mode, gedit on Linux and bbedit on the Mac support remote editing, too. Probably quite a large number of other editors. In that case you would just edit in on a more capable desktop and restart the script from a shell window.
For what it's worth, VIM alone can do the same tasks as previously posted. I have had the same problem with testing Python from the command line.
My solution was to use the screen command. I split screens vertically, I run Python in one instance of a shell, and on the second screen, I usually edit Python code with VIM.
Command to install screen:
sudo apt-get install screen
The screen package has a bit of a learning curve but there isn't any mystery if you can remember the "Ctrl-Alt ?" command that contains all knowledge.
No GUI is required!