I'm using mac osx mavericks (fully updated) and while looking for a pyscripter alternative, I decided to download CodeRunner from the app store.
I've noticed that certain programs I create in one application, don't always run the same in the other environment.
For example, there are times when I create a program using CodeRunner, but when I open the exact same program in the IDLE environment, it spits back an error. Usually complaining about the syntax or logic of the program. And the other way around can sometimes occur as well.
Is this normal behavior? Should I be saving the program in a different format? I assumed that since I'm coding in Python, the code would behave the same regardless of the environment I use.
The different programs probably have different definitions of tabs and whitespace.In IDLE, you can use Format->Tabify/Untabify menu options to change between tabs and spaces. When you click on these menu options, you prompted for the columns per tab, which will default to 4(At least on my machine). Hope this helps!
Related
I created a python script to control the RGB of my keyboard and my mouse and i want it to start when i turn my computer on. I have 2 solutions but i don't know which is the best.
the first solution is to build my script and run the executable on startup
the second solution is to run directly the python script with python.
the first solution is a little bit annoying because is i want to change the code, i need to rebuild my script. and also when i tried to run the exe (created with pyinstaller), it didn't work (because of the dlls i think)
the second solution is better if i want to change the code later, but i don't know how it would react if i run another python script (i don't even know if it's possible to run 2 python instances at the same time.)
so if you have any idea on which solution to choose, how to build a script using dlls with pyinstaller or if i can run multiple python instances (maybe i can run multiple venvs), feel free th help me.
PS: I tried to be clear but as i didn't speak english very well i don't know if you understood my issue.
Using windows : https://www.geeksforgeeks.org/autorun-a-python-script-on-windows-startup/
Using Linux : follow this https://stackoverflow.com/questions/24518522/run-python-script-at-startup-in-ubuntu#:~:text=Put%20the%20command%20python%20startuptest,and%20put%20the%20command%20there
I do most of my Python coding in Notepad++. I would like a way to quickly and easily reformat my code using the default rules from PyCharm - things like spacing, number of blank lines between functions etc.
I find black playground too harsh for my requirements, and opening up PyCharm to paste code and reformat it defeats to purpose of using Notepad++ (for it's lightness).
So do you know of either a plugin for Notepad++ which does this (and I'm not just referring to Python Indent), or an online resource which applies PyCharm style formatting to pasted code?
PyCharm comes with a CLI, like documented here https://www.jetbrains.com/help/pycharm/command-line-formatter.html.
Alternatively and making the call slightly shorter: parallel to the mentioned there general batch file, you probably also have 'format.bat'. You can integrate this into Notepad++ via the [F5] button "Run...":
Put there
C:\__YourPyCharmRoot__\bin\format.bat "$(FULL_CURRENT_PATH)"
and press the [Save] button in this "Run..." dialog to assign a short-cut.
Pressing the newly defined short-cut on a saved and writable Python file should let Notepad++ ask you after a while (of running PyCharm in Windows cmd.exe) to reload the changed file .
This is mostly a question regarding work-flow in Spyder, and not a pure programming question. If anyone thinks it has no place here, then please let me know and I'll remove it.
Here we go:
I'm running Spyder on a Windows 64-bit operating system. The interaction between the Spyder IDE and IPython console depends on how you choose to run your code, and I would like to specify how this interaction works.
Among several options to run parts of the code, the difference between the following two is what puzzles me:
Option 1 - Select parts of the code and hit F9
This runs the selected code. No surprise there.
Hit F9 again, and the same selection is executed once more.
Option 2 - Run the same selection using Cells (#%%) and Ctrl+Enter
The code is run just like before. But hit Ctrl-Enter again, and nothing happens. Probably because the IPython console now is the active window.
I would like to find some way of changing this so I can use Ctrl+Enter and run the cell contents multiple times without having to make the Spyder IDE the active window by manually clicking on it. I don't know if this is possible at all. Googling and messing around in the settings under Run / configure and Tools / Preferences has so far been useless.
Thank you for any suggestions!
P.S
In case you're wondering why this is such a big deal to me, I'm rendering multiple charts and exporting them to Power Point with minor changes each time the code is run. This way, new parts of the charts (lines, textboxes, etc) are revealed when I'm working my way through a finished Power Point presentation. And for my basic data science needs, this has turned out to be a pretty much optimal work-flow. Except, of course, that I have to manually select the Spyder IDE each time I run different selections of the code.
In the latest spyder version, the keyboard shortcut to run the highlighted lines of code is F9 but it doesn't seem to work.
Go change it from TOOLS>>PREFERENCES>>KEYBOARD SHORTCUTS then double click on any shortcut you want to change and change with your shortcut. But be very careful if you used the same shortcut that is used for any other work then for that it will remove.
I changed the shortcut for 'run selection' from F9 to ctrl + Enter
in Option 2, you should use Shift+Enter instead
So, recently I was using the Python theme function for the IDLE program itself. I downloaded three themes and built my own one, which is selected now. The problem is, I forgot to set colours for the blinker and highlighting, which is hugely problematic. When I went to see if I could change back to the default setting, Python IDLE simply froze up when I selected 'Configure IDLE' under options. I can still scroll through the file, attempt to close the window and minimise it etc, but it has just frozen up. I can't close it or continue working with the file. I've removed Python and then reinstalled it but that hasn't worked, should I just manually delete the themes and force IDLE to use the original one, or is there a way to fix this?
I am running Python 2.7 on Windows 8.1.
Thanks
Turns out one way is manually deleting the faulty theme. This allows the Configure IDLE menu to open. Whoops.
I use IPython very frequently and happily. Somehow, cutting text from the shell using the keyboard shortcut, Ctrl + X, is broken. Actually, I have a few different installations of IPython. In some of the installations, the shortcut works; in the others, it doesn't work.
What might be the reason for this? Where should I look into?
You say you have multiple instances installed -- are these all on different machines? What operating system(s) are they running? If you access them remotely, what operating system are you running?
Do you get to them using ssh? Do you run something like screen, either locally or remotely, or both? There are lots of things that can interfere with your terminal settings, especially when you're working remotely.
I'm almost certain that iPython doesn't have anything to do with it -- though you might want to check the version numbers, to see if working and non-working environments are running different versions.
More likely, it is something in the terminal emulation layer, but you'll likely have to do some detective work of your own to find out what piece is causing it.
Take it one step at a time -- try to cut from a local shell, to make sure that works. Then connect to a remote machine, and cut from that shell. Start screen, if that's your normal way of doing things, and test from that shell. Then start ipython. If it stops there, then see if you can find another application on the same machine that's linked against gnu readline, and try that. You may find that none of the console apps cut proplerly on that machine, or you may find that they work, but not under screen. Or you may find that something in the terminal settings stops everything from working as soon as you ssh in.
You may also have some luck. if you can find out what terminal the remote machine thinks you are using ( echo $TERM ) by copying the termcap file from a working machine to one that doesn't. That's a bit more involved for these forums, though -- I'd repost at that point on serverfault.com or superuser.com
I hope that at least gives you a starting place -- terminals are finicky, and difficult to get right. Most people seem to not bother, as long as everything mostly works.