After creating a .ipynb file in the root directory /, how can you move that .pynb file into a deeper directory ie: /subdirectory using the web UI?
As of Sep-21 2015, there is no direct feature that supports moving files. However, there is a simple workaround. (*)
Select the file that you want to move.
Click Rename
Add the new path to the beginning of the filename.
Click OK
That's it. You should be able to find your file in the new path.
(*) https://github.com/jupyter/notebook/issues/471
The steps below may be an overkill to explain how to move a Jupyter notebook file from one folder to another using Jupyter. . However, it may be useful for someone who may be trying this the first time.
Let's look at an example (with example screenshots) to move "practice.py.ipynb" from "/Learn/python/puzzles" folder to "/Learn/python/puzzles/exercises" folder.
Step 1: Check the status of "practice.py.ipynv" notebook
If status is "Running" then the option to "Move" the file will not show. Follow along to "Shutdown" the notebook.
If status does not show "Running" then proceed to Step 4.
Image link shows the status of the notebook. In our example it is "Running"
Step 2: Select the notebook by clicking the checkbox next to it.
Image link shows the options for the selected notebook. "Shutdown" is displayed as an option. Move is not an option for a running notebook
Step 3: Click the "Shutdown" button for the selected notebook to stop the "Running" notebook. Image link show the notebook is no longer running
Step 4: Select the notebook by clicking the checkbox next to it. Image link shows the options for the selected notebook. "Move" is displayed as an option
Step 5: Click "Move" button. A pop-up window is displayed with the current path (folder) of the notebook. Image link shows current path as "/Learn/python/puzzles"
Step 6: Specify the folder where you want to move the notebook. Then click the "Move" button on the pop-up window. Image link shows here in our example, we would like to move it to "/Learn/python/puzzles/exercises" folder
File is no longer displayed in the current folder "/Learn/python/puzzles". File is no longer in the current folder. Image link shows practice.ipynb file is not in "/Learn/python/puzzles" folder anymore
Step 7: Click the exercises folder to navigate to "/Learn/python/puzzles/exercises" folder.
Image link shows notebook "practice.ipynb" is moved to "/Learn/python/puzzles/exercises" folder
If some stumbles here as of 2020, it's now possible to move .ipynb or other kind of files by simply checking it and clicking move.
Nevertheless, for .ipynb files you must be sure that the notebook isn't running (gray icon). If it's running it should be green and you must shut it down before moving.
It's kind of a workaround, but you can do this:
Navigate to the directory you want to put the file in
Click the Click Here
Find the file and upload
Ipython 5.1:
1. Make new folder -- with IPython running, New, Folder, select 'Untitled folder' just created, rename (and remember the name!)
2. Go to the file you want to move, Move, write new directory name at prompt
Note: If the folder exists, skip 1.
Note: If you want to leave a copy in the original directory, Duplicate and then move.
Ran into this issue and solved it by :
Create a new folder in jupyter notebooks.
Go to the folder/directory and click the "Upload "button which is next to the "New" button.
Once you click "Upload", your pc file explorer window will pop-up, now simply find where you have your jupyter notebooks saved on your local machine and upload them to that desired file/directory.
Although this doesn't technically move your python files to your desired directory, it does however make a copy in that directory. So next time you can be more organized and just click on a certain directory that you want and create/edit/view the files you chose to be in there instead of looking for them through your home directory.
Duplicate the notebook and delete the original, was my workaround.
JupyterLab (based on version 2.1.5), does not appear to have a direct move functionality (AFAICT), but does provide yet another workaround:
Right-click on the notebook file you want to move
Select "Cut"
Navigate to the destination folder to which you want to move it
Right-click in that folder (anywhere inside)
Select "Paste"
Note that the cut file doesn't immediately disappear from the original location when you cut it, but will be removed from its original location after pasting into the destination folder.
Related
really simple question.
I have a URL here that I'm trying to open in Jupyter lab as a jupyter notebook. What is the easiest way to do this? Is there a command line command somewhere?
Thanks.
step 1:
visiting the URL "ctrl + s" to download that file (you would get the file name as xxx.ipynb.txt)
step 2:
Start jupyter notebook. Find the directory where you save to and double click file to open it.
step 3: Change it's name from 'xxx.ipynb.txt' to 'xxx.ipynb'. (delete .txt in the last of file name)close the window and open it again.
I think it's work!!
Just download that file to a working directory - with a menu 'save link as...' or visiting the URL and doing save.
Start juypter notebook from shell (commandline).
In the directory window that it opens for you, double click the saved style.ipynb. Now you have the notebook running in a new window.
I'm using jupyterNotebook from Coursera but see no way to revert everything to the beginning.
The only option relevant seems to be "Revert to Checkpoint" -- but I didn't save a checkpoint at the beginning.
Does it mean that I am unable to revert to it?
Open your notebook at Coursera
Rename it
After renaming just add ?forceRefresh=true to the end of your notebook URL
Hit enter
You now have old renamed version and new refreshed to default one
The procedure is described here.
As of July 2019 the ?forceRefresh=true solution worked for me.
These steps will work as of April, 2020:
Rename your notebook and add ?forceRefresh=true to the url and press enter. Your entire Jupyter notebook will be restarted. Go to the course week and a fresh notebook will be there.
Better late than never -
This is from the Coursera help section.
To keep your old work and also get a fresh copy of the initial Jupyter Notebook:
Make a copy of your Notebook by clicking File, then Make a copy. We recommend using a naming convention such as “Assignment 1 - Initial” and “Assignment 1 - Copy” to keep your notebook environment organized. You can also download this file locally.
Click Control Panel, then choose My Server
Find the name of your previous file, as well as the new copy of your file.
Delete the original notebook file (not the copy) by selecting the checkbox next to the filename. Click the trashcan icon that appears to delete the file.
Click Control Panel, then choose Stop My Server.
Select My Server to restart.
After a few minutes, launch the notebook again from your Course Home. If you get a 404 error while the notebook server restarts, wait a few minutes and try again.
After the restart is complete, you will see a fresh copy.
I believe this is a new feature in Coursera
This is the instruction from a course I was taking:
In any Jupyter notebook, first save your work by going clicking File -> Download as -> Notebook (.ipynb)
Next, click File -> Open. This opens up the file directory.
Select the notebook you wish to refresh from the list by clicking the check box next the the filename
Click the trashcan icon at the top to delete the notebook
Copy this text: ?forceRefresh=true and paste it onto the end of the URL in your browser bar then hit .
You will see your workspace refresh with the updated copy of the notebook
These steps:
1. Open your notebook at Coursera
2. Rename it
3. After renaming just add `?forceRefresh=true` to the end of your notebook URL
4. Hit enter
5. You now have old renamed version and new refreshed to default one
Still work as of 05/14/2021
I installed Spyder using Anaconda, and I am able to launch the IDE using the Spyder icon in my start menu (Win10). I wanted to set my preferences to open all .py files with Spyder, so I followed the Spyder start menu button to an executable, pythonw.exe. The problem is that I cannot launch pythonw.exe by clicking it.
How does the start menu icon for Spyder, which points to pythonw.exe, launch Spyder, but clicking the executable does not yield the same results? Also, when I double click spyder.exe in Anaconda\Scripts a command prompt opens along with the IDE, which does not happen when I click the start menu icon.
Why does this application behave so much differently than any other application I've used before (if this is just how things are in python, I apologize as I'm new!) and is it possible to set Spyder as the default application to open .py files in the same way I can open source files with IDEs in other languages?
Cheers
I found the answer in this question, answer by xyzjayne.
You create a bat file with the following contents:
start YOURPATH\Anaconda2\pythonw.exe YOURPATH\Anaconda2\cwp.py YOURPATH\Anaconda2 "YOURPATH/Anaconda2/pythonw.exe" "YOURPATH/Anaconda2/Scripts/spyder-script.py" %1
YOURPATH will be the path leading to the folder just above the Anaconda folder. For me it was:
C:\ProgramData
And you select the Choose default program to open this file... - and you choose that bat file.
When you go to Spyder shortcut's properties, the target includes a few files. So my guess is that for Spyder to run, all of these files must be run, and that's why when you just point .py files to one exe it doesn't work.
You can right click any of your *.py file, go to properties and choose Spyder as "Opens with" choice.
Right click on your file, and select open with or Choose default program to open this file.. and then in your system... select .. \Anaconda3\Scripts\spyder.exe .
I have also provided you the screenshot of the above path in my system for your reference.
In Windows 10 Anaconda installs itself into a hidden folder called ".anaconda" which is placed in the Users directory under your own profile sub directory.
When you first try to use the right-click menue "Open with" it opens up in C:\Program Files so you have to go up one folder and down into Users. You may need to have previously set one of the options in the View Menu of the file manager so that you can see hidden files. You can't do this from the "right-click open with" place, you have to set that in the regular file manager.
You will find a file called Spyder.bat a couple of folders down within that, e.g. C:\Users\Your_profile.anaconda\navigator\scripts
It will take forever to open each time.
for Anaconda3 on win11:
start YOURPATH\Anaconda3\pythonw.exe YOURPATH\Anaconda3\cwp.py YOURPATH\Anaconda3\ "YOURPATH\Anaconda3\pythonw.exe" "YOURPATH\Anaconda3\Scripts\spyder-script.py" %1
Below a baby-step guide to make Spyder your default program to open .py, including an icon!
First, search for Spyder in windows, and open the folder that contains spyder. Spyder will be a short-cut file. Right-click the spyder shortcut file and choose "Properties". Copy all the contents of the "target" content.
Open a Notepad. Write the word start and the paste the contents you obtained in step 1. Now, save the file as .bat, with any name you want, let's say "myspyderlauncher.bat", in a convenient location for you.
Go to any .py file, and choose "open with", and look for your .bat file (following the example above, the "myspyderlauncher.bat" file). Choose "always" to always open .py files with your bat.
Now double click the .py file and Spyder will automatically be started. Voilà!
Did you say you want a nice spyder icon too instead of that ugly white icon? Here are the next steps (optional):
Download Bat to exe converter (not worries, you will not need to install the software): https://web.archive.org/web/20190304134631/http://www.f2ko.de/en/b2e.php
Unzip the Bat_To_Exe_Converter.zip and go to the "portable" folder and run the .exe file. Open your .bat file ("myspyderlauncher.bat" in the example above), and then go to the right menu, click and look in the "icon" option and look for the Spyder icon (.ico file), which is normally in ...\Anaconda#\Scripts.
Now press "convert" in Bat_to_Exe and save your new .exe file in a convenient location with a convenient name you want. (Let's say we call it "spyderlauncher.exe")
Go to any .py file, and choose "open with", and look now for your .exe file (following the example above, the "spyderlauncher.exe" file). Choose always to always open .py files with your bat.
You will see that all your .py files are now associated to spyder, with a beautiful icon attached, and opening in Spyder.
Some screenshots below
Hi I'm a beginner with Python. I have installed Python Tools for VS2015.
I have created a project called Learning_Python, so VS2015 has created a Learning_Python.sln file, a Learning_Python folder and a Learning_Python.py file inside that folder.
In the Learning_Python file i have a script with whatever instructions.
In solution explorer, i have right clicked on "Learning_Python" and added an existing file, called requestwebpage.py, with some Python script.
now when i click on the green arrow "start" in VS2015, the script Learning_Python.py will execute, but NOT the script in requestwebpage.py
why is it so ? basically, i don't want to create a new project everytime for every possible .py file ...
thanks
here is a partial answer:
i right-click on requestwebpage.py in solution explorer and i could set it up as the startup file. alternatively, right clicking in solution explorer on Learning_Python solution, i can choose "properties" and modify the startup file in the new window...
That solves my problem, i believe.
I am developing a key-logger on Python (only for curiosity sake). And the script will be an executable. The process will not need a UI or user interaction.
Is there any way, even in another executable to make the key-logger start at start-up?
I don't use Windows, but you can try making a batch script that runs your python file and make that script Run a program automatically when Windows starts:
Click the Start button Picture of the Start button , click All
Programs, right-click the Startup folder, and then click Open.
Open the location that contains the item you want to create a shortcut
to.
Right-click the item, and then click Create Shortcut. The new
shortcut appears in the same location as the original item.
Drag the shortcut into the Startup folder.
As I said, I don't use Windows, so it might be totally wrong.
You can refer here for making the BAT file, which basically says:
#echo off
python c:\somescript.py %*
pause
I think that the above answers are too complex. What I did was just drag and drop or copy and paste my file in the startup folder by clicking the quick access toolbar, typing "startup", and the job is done.
I am using Windows 10 operating system, so it might be different in your case.
I hope this is useful.
Edit: The key to this solution is to have the .py extension files open by default by the python console (not a text editor), otherwise it will just open the file instead of executing it. In order to select the default program a type of file is opened with, right click on the .py file -> Open with -> Choose default program. See this example:
Use VBScript:
1-> create anyname.vbs with this data:
Set wvbs=CreateObject("Wscript.Shell")
wvbs.run "full location of your File",0
2-> copy anyname.vbs file in C:\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup this folder
Now when windows start it will run your file in hidden mode
Open run with "Start + R", then open "shell:startup". it opens you a folder(the folder that was mentioned before at start menu), and every file that is on this folder, well run at startup.
The folder path is: "C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" (you can copy it on windows explorer, or copy this path and put your account name on USERNAME)
this is the trick i used in my script:
from os import getcwd
from shutil import copy
copy(getcwd()+'/FILE_NAME.exe','C:/Users/USERNAME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup')
They are some ways for file name as well, but im not familiar with it. this code copies it self to startup folder and starts each time windows boots
Create a shortcut in the shell:startup folder with an absolute path to your pythonw.exe executable. The w version of Python is needed so that it starts up without a shell in the background.
Detailed instructions
Open the startup folder
Type the Windows and R keys at the same time. In the Run dialog, type shell:startup and it enter. This takes you to the Startup folder. Shorcuts in this folder are launched when the computer starts. (For me, the startup folder is at C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.)
Create new shortcut
Right-click in this folder and say "New shortcut." Browse to "This PC," "Windows (C:)," "Program Files,", "Python39", and select pythonw.exe. Your Python install is likely in a different location. More recently, Python is found somewhere within %appdata%. (You can paste %appdata% into the run dialog to open this folder and look for Python. It opens in Roaming by default, but be sure to look in Local, too.)
As mentioned at the start of this answer, it is important that you select pythonw.exe rather than python.exe as pythonw.exe will run without opening a command prompt.
On the next "Create Shortcut" screen, titled, "What would you like to name the shortcut," you can name it whatever you want. For the OP, I recommend "Self penetration test."
Click "Finish."
Edit the shortcut to launch your script
In the Startup folder, right click on the app you just created and select "Properties."
In the Properties dialog's Shortcut tab, edit the "Target" to look something like "C:\Program Files\Python310\pythonw.exe" pentest_keylogger.py and the "Start in" to be the folder in which pentest_keylogger.py is found. (As above, you will need to use your Python distribution's path.)
Test your script
Hit OK. Then double-click on the icon to see if it works silently as you desire.
Finally, reboot your machine and use resmon (from the run dialog) or Ctl-Alt-Delete and the task manager to see if your app is running in the background.
Acknowledgements
Thanks to Eryk Sun and Behfar baghery for the core ideas presented here.