I am using Enthought canopy for data analysis. I didn't find any option to create a .py file to write my code and save it for later use. I tried File> New >IPython Notebook, wrote my code and saved it. But the next time I opened it within Canopy editor, it wasn't editable. I need something like a Python shell where you just open a 'New Window', write all your code and press F5 to execute it. It could be saved for later use as well. Although pandas and numpy work in canopy editor, they are not recognized by Python shell (whenever I write import pandas as pd, it says no module named pandas). Please help.
Umair, ctrl + n or File > Python File will do what you want.
Best,
Jonathan
Let me add that if you need to open the file, even if it's a text file but you want to be able to run it as a Python file (or whatever language format) just look at the bottom of the Canopy window and select the language you want to use. In some cases it may default to just text. Click it and select the language you want. Once you've done that, you'll see that the run button will be active and the command appear in their respective color.
Related
I took help from this website https://www.geeksforgeeks.org/make-notepad-using-tkinter/ and used the code to create a full-fledged text editor which was like the windows Notepad.
Now, I want to integrate a terminal into it so that it can run the programs there itself.
refer this:
os.system()
make sure to check the path of the file that you want to run
I just started learning python. Up until now, I primarly worked with jupyter notebooks, but now wanted to try out some IDEs. So I tried out PyCharm.
So I started creating some files in a project and started trying out the commands and stuff and there is one thing which just drives me crazy, cause I can not seem to find an answer.
Everytime I create a new python file and name it something like "simple_message", it just saves as a normal file and I can't run any code in it. As soon as I remove the underscore, the file convention changes to an actual python file and I can run the code written in it. So I thought it might be the underscore that makes trouble, so I tried creating other files with underscores but all of them worked. Can someone enlighten me, why does the file name "simple_message" not work as a python file?
Thank you!
From this To this
For me I have to right click on a directory (folder) and select "New" → "Python File" to make a python file. If I go "New" → "File" it will create a text document. So long as you click the correct option you shouldn't have to worry about typing the '.py' or '.txt'
Alternatively I can right click and select "New" → "File" and then name it "simple_message.py" and it will save as a python file correctly, but I must include the .py using this method
Currently PyCharm context menu lets you choose the file type to create.
If you choose "file" you MUST provide the extension .py
If You choose "Python File" pycharm handles the extension for You.
You may need to right click in the text of your .py file and manually choose run from the menu.
Pycharm doesn’t automatically reindex when you create a new .py file, and so it probably just doesn’t know what you want it to run when you hit the green play button.
If you’re saying your python interpreter won’t run a .py file because it has an underscore in the name, that’s just not possible unless you have a modded interpreter or have done something really strange to your OS and I’m guessing you haven’t done either.
Update: it sounds like you don’t have the .py file extension on your file. This will not run for reasons that have nothing to do with Pycharm. Pycharm may “bridge the gap” for you automatically in some situations, but no reason to rely on that.
It would be really handy to have a button to copy raw code from a Jupyter notebook to the clipboard so it can be dumped into a text file, .py/.R script, or straight into the terminal (a button like github has to copy to clipboard)
Does a button (or even a chrome add on) exist?
Obviously you could copy/paste sections manually into a txt file, but that's laborious for long notebooks/markdowns
Yes,there is a button:
File > Download as > Python (.py)
There is a more handy way for Mac OS users.
By installing an Automator script converting the ipynb file to py first, then automatically copy the content to the clipboard with one right-click and select the script in the Quick Action part.
Github link
You can use the magic command %%writefile to save as py file
%%writefile "directory/to/file/filename.py"
However, you should place this command at the top of the cell, otherwise it will throw an error.
I am using mac OS X Sierra with Mac for Ecel 2016 and python 3.6. I am trying to launch a python script from excel because:
I already have an excel with a lot of functionalities and I would like to add some features to this product using Python.
The users of my product won't be comfortable launching python scripts from a python console, so I'd like to have some kind of excel user interface.
I am providing this background because I am open to suggestions on how to do differently. From my researches so far, it seems that this can be done using the xlwings library. I have tried using it following the instructions on:
http://docs.xlwings.org/en/stable/vba.html#vba
I am somehow stuck at this stage:
Open the VBA editor with Alt-F11
Then go to File > Import File... and import the xlwings.bas file. It can be found in the directory of your xlwings installation.
As alt + F11 doesn't open the macro editor, I have understood the instructions as follows:
click on the 'macros' button in the 'developper' tab of excel
create a new macro / edit an existing one
go to 'add references' on the bottom left corner
open the file mentioned
The issue is that I can't open the xlwings.bas file ; I can only open some of the files. I managed to open a file called xlwings.xlsm ; that creates a new tab called 'xlwings' on Excel, in which there is one button: 'import Python UDFs'. When I press this button it throws the error :
Run-time error '53':
File not found: xlwings64.dll
In one of my previous attempts using xlwings, I had a different error at this stage. I cant remember it, but from my researches the solution implied doing something on the trust center of excel 2016 which I couldn't do with Excel for Mac 2016.
Alternatively, when I try to run a macro using RunPython, it throws the following error :
Compile error:
Sub or Function not defined
Pointing at RunPython...
If someone knows what I did wrong and/or how I can manage to use xlwings, that would be great.
Thank you for the help,
For your information, the best solution that I found (thanks to Xukrao) was to download an example from xlwingsexamples, go to the macro editor, copy the "xlwings" module that is in the example worksheet and paste it in the macros of my worksheet.
The fastest way to create a new project according to https://docs.xlwings.org/en/stable/command_line.html is to use the CLI
xlwings quickstart myproject
This will create an .xslm and a .py file.
I am trying to write the Python BPY -code inside Blender and noticed some editor -mode (source) and, instead of reinventing the wheel, I want to use my Vim -syntax-highlighting-etc inside Blender -text-editor. So how can I use Vim inside Blender?
You can write scripts either in an external text editor, or in
Blender's built in text editor. Move to a panel you wish to change to
be the text editor, click the editor select button and choose "text
editor" (shortcut) SHIFT+F11. Click the + New button at the bottom.
If you want, you can enable line numbers and syntax coloring with the
buttons at the bottom. Create a new script with File → New, paste the
code below into it, and save it. Or alternatively, paste the code
below into a file, and open that file with File → Open in Blender. As
name choose something with the extension .py, for example
wikibooks.py. Put it into Blender's user scripts path.
From the source you provided it looks to me that it doesn't matter what text editor you use as long as you save the python scripts to the file locations provided in that documentation (e.g. ~/.blender/scripts and other OS paths). Not very familiar with blender since I'm answering via the vim tag. Looks like there's potentially a plugin to use an external editor: http://www.blendernation.com/2011/08/02/edit-blender-text-files-using-external-text-editor-plug-in/. Also if you're on Mac then look into QuickCursor: http://www.hogbaysoftware.com/products/quickcursor/.