I am completely new to Atom.
I installed it and it felt quite easy to use and set up. I read that the Hydrogen package enables functionality similar to the Jupyter Notebook. So I installed the package.
Unfortunately, I have no Idea how to use it. I read the entire documentation (which isnt too extensive) and searched for everything I could.
So here is my problem:
I created a file called testfile1.py
In that file i put the very simple line
print(‘Hello’)
just to see how it works. I marked the line and pressed Ctrl+Enter. At the top right, a window pops up saying “Hydrogen Kernels updated: Python 3”.
But then nothing happens. I dont see the result of the code that I tried to run anywhere. I tried different lines of codes, tried differen run-combinations, nothing gives me any results.
I am using arch linux, installed Anaconda through the AUR to /opt/anaconda.
Using the terminal and running
jupyter notebook
for example works just fine and opens a Notebook in Firefox (as it should) and running code that imports modules that came along with Anaconda also work fine once i run them with the script package in Atom
(things like
import numpy as np
is letting me work with all the numpy funtions as expected. So I think that it shouldnt be any issues related to the Anaconda packages itself)
I tried to look everywhere I could, but I do not find any solution on why hydrogen would not give me any results.
Is there anything I am missing or did wrong?
I hope someone might be able to help me, thanks already in advance
I'm using Windows 10, Atom version 1.30.0 with Hydrogen 2.6.0 (both with default settings).
If you navigate to Packages > Hydrogen you can see the default key bindings.
To make a cell there are many options noted in the manual as shown below.
I found I had to re-start Atom after updating the python kernel. Then the run code commands worked as expected.
You need to select all the lines which you want to execute with the cursor and then press ctrl+enter (or shift+enter depending on your keybinding).
There are two ways to tell Hydrogen which code in your file to run.
Selected code:
If you have code selected when you hit Run, Hydrogen will run exactly that code.
Current block:
With no code selected, Hydrogen will try to find the complete block that's on or before the current line.
If the line you're on is already a complete expression (like s = "abracadabra"), Hydrogen will run just that line.
If the line you're on is the start of a block like a for loop, Hydrogen will run the whole block.
If the line you're on is blank, Hydrogen will run the first block above that line.
Related
For some weird reason, Visual Studio hasn't performed correctly what I've been doing in python. Unlike all the tutorials I find, where they normally run in the "output" field, in mine it displays correctly only in the terminal.
print('test','trying', sep='#')
Output:
File "/Users/x/Desktop/Livre.py", line 2
print('test','trying', sep='#')
^
SyntaxError: invalid syntax
Terminal:
test#trying
Here is an example of the SEP command, but the same thing happens, for example, when I put special characters in lists, even when I use utf8.
Does anyone have an idea why this is happening?
EDIT:
So, I understood what is happening, like was told in one of the answers: Visual Studio Code is using python version 2.7 in the "Output" field, for some reason, even though I have installed and reinstalled Code Runner and Python 3.10 several times.
Unfortunately so far it hasn't solved the problem.
But I haven't given up yet, and somewhere here in Stack I wiil discover how to figure it out :)
Install and run the code with Code Runner.
After installing this extension, the triangular play button in the upper right corner will have three options
Select Run Code to run the code, and the result will be output in the OUTPUT panel.
Right-clicking directly on the editor interface and selecting Run Code is the same.
Tips:
Among the three options, Run Code is provided by Code Runner, and the other Run Python File and Debug Python File are provided by Microsoft's official extension python.
End goal: After running a script regardless of ending perfectly or erroring out, I would like to have my ipython environment revert back to the directory it was in before running the script.
I have successfully used the advice given in the SO post,
how-do-i-change-directory-back-to-my-original-working-directory-with-python.
This works great if the script runs without failing.
Ideas:
1) I have considered wrapping my code in one large try: and except: utilizing the advice in the post mentioned above. As this would surely handle the issue. However, it seems tedious and unnecessary to have to write this into all my scripts.
2) I was thinking a good a solution would be to have ipython automatically run a "revert directory" script after every user ran script, that would change the directory back to the original one. I have looked around a bit to see how one would configure ipython to run a script automatically after every run. From my search so far I have not found this to be an option. I was expecting to find a method to accomplish this through the ipython config file.
3) Another solution that would be easy would be to somehow use the information found by using the line magic command %dhist. As the first result given by this command is the original directory that ipython was opened in. However, other than having the results print from executing the command %dhist... I am not sure how to work with the printed information.
4) I must be not searching the right terms, as I feel like this is probably something that is possible or has been asked. If indeed someone has asked this, please point me in the right direction and I will remove this question promptly.
Relevant information:
Working on os x
Using Jupyter QtConsole 4.3.1
IPython 6.2.1
I am trying out IntelliJ. I have installed the Python plugin, and IdeaVim.
I cannot navigate properly across Jupyter Notebook cells using hj. I mean, on normal mode, I cannot go to the next (or previous) cell, even if there is one, using hj.
Is there a way to do it without the mouse, possibly rebindable? I have read the tutorial and tried to find something in the program, but could not.
Ideavim plugin doesn't seem to support Pycharm's notebook implementation as of right now :(
There's an open issue marked as "bug" on Ideavim's issue tracker that was opened back in 2015 and it seems like it doesn't have any progress made since.
However according to the comment in the issue thread you can:
funny way to get into the command mode is type something so that the suggestion panel appears, now press "esc" you will get into Vim command mode
So this might indicate that this could be solved and updated in the future.
As an alternative you can try out jupyter-vim-binding, however it doesn't work with Pycharm either.
Many python IDE's boasts of providing code-completion (code insight), PyCharm is one of those IDE's. However, it seems to me that the provided code-completion is extremely limited. Let me give you an example to make it clear:
import numpy as np
m = np.random.random((3,5))
m.
Hitting CTRL-space after 'm.' will not give me any code-completion, -no matter how hard I hit it ;).. I guess this is because the IDE would have to do type inference to know the type of the variable 'm', and that this isn't trivial in the domain of dynamic programming languages.
Now, PyCharm comes with a setting called "Collect run-time types information for code insight", which indeed sounds promising. However, it doesn't seem to fix the problem mentioned above.. I am still not able to get code-completion on the variable 'm'.
Thus far, I have only found one way to get code-completion on variables in PyCharm:
import numpy as np
m = np.random.random((3,5))
''':type : np.matrix'''
m.
In this example I am able to get code-completion when pressing CTRL-space after 'm.', and this is because I am helping the IDE by specifying the type of the variable with a docstring. I am, however, not satisfied with this way of getting code-completion, because it adds unnecessary verbosity to the code with all these docstrings (not to mention all the extra keyboard-typing)...
IPython to the rescue.. (maybe?)
Now, if we start IPython in a linux-terminal, and enter the first piece of code, we will be able to get code-completion all the way, -even for the variable 'm'. (where the code-completion in IPython is achieved by pressing TAB instead of CTRL-space)..
I don't have much experience with IPython, but I believe that I've heard something about IPython constantly executing the code in a loop or something like that...
I am thinking that it should be possible to use IPython to achieve REAL code-completion on all variables in the editor of PyCharm....
Is there a way to setup PyCharm to use IPython for code-completion?
Note that I am not satisfied with sending the code to a terminal window/console, or something like that, I want code-completion inside the editor of PyCharm...
I have looked at questions like this Adding ipython as an interpreter in Pycharm Ubuntu, but it seems to be about using IPython in the console, -not in the editor... There are also plenty of questions talking about code-completion in IDE's, but they all seem to have the same unsatisfying level of code-completion as PyCharm...
My setup
OS: Debian testing
python: Python3 and IPython3
IDE: Pycharm 3.0.2 professional edition
It cannot tell what returns are from functions(with out actually running the script, thats why ipython knows what it is (it has actually run the code and recieved back an object it can introspect)
if you want code completion without having to actually execute your script up to where you are entering text you have to do an extra step
import numpy as np
m = np.random.random((3,5))
assert isinstance(m,np.ndarray)
m. #now you get code completion (since the IDE now knows the class of m, without having to execute your script)
I had the same question, I found the answer here:
https://www.jetbrains.com/pycharm/help/using-ipython-notebook-with-pycharm.html
What you need to do is to create a ipython notebook in the project tool window. This is a file with the extension '.ipynb'. Right click on the directory where you want to put the file, select 'New-->File', enter a file name in the dialog box and give the file extension .ipynb. Open the notebook file and when you start to type something in the window, a drop down window appears with objects in the namespace plus any commands that start with the letters already typed.
To achieve iPython like functionality in pycharm, you can do it two ways:
setup a breakpoint, and debug your code. when it reaches the breakpoint, go to the console tab right below the editor, and launch a command line by clicking the button that says show command line
Launch a python command line from your console (without running debugger), by clicking on Tools, Run Python console
EDIT: The code I wrote in my Python file was just this:
print "foo"
I'm using Windows XP Home Premium on this tiny little HP Mini 1000, and I want to run Python files, since we're learning it in school. I am aware of this topic, so I tried to run Python files using a batch file (python.bat), and I'm getting an error that says, "Can't find 'main' module in ''" whenever I run the batch file. I followed the instructions given here. All I did was change "Python26" to "Python33" because of the difference in versions.
Any idea what's wrong here? I really want to run Python files from Notepad++, so I don't want any alternative ways to run them.
This sounds like you don't have PYTHONPATH set up correctly. I suggest you review the documentation here:
http://docs.python.org/2/using/windows.html
Instead of calling Python, call cmd.exe and then use the set command to inspect which variables are set and how they are set. Run the exit command to leave the command shell. When you think you have the variables set up correctly, try again to run Python.
Good luck and have fun!
I use the command line interpreter or IDLE mostly (Win 8.1 now, but I've done so since Win XP SP2), but NPP is my main text editor, so I was curious about this issue.
When I was reproducing this, I was able to generate several errors, but the only one I got that was an exact match was when I failed to configure the Run option correctly.
You need to make sure to follow this step exactly in the instructions you were following. When you navigate to Run -> Run in Notepad++, you have to enter this exactly:
C:\Python33\python.bat "$(FULL_CURRENT_PATH)"
I am pretty sure you left out the "$(FULL_CURRENT_PATH)", or otherwise didn't add it correctly, as failing to do so causes exactly the same error on my end. Failing to include this means that when you run the batch script, you get the wrong input to the Python interpreter, causing the error.