I am trying to make a copy of a readonly jupyter notebook (made by setting the chattr i bit with a 644 permission). The notebook copy fails when the kernel is set to Python2 or Python3. It only opens a blank page. Interestingly a similar notebook with a R kernel successfully makes the copy.
Does jupyter kernels have special calls for this make a copy UI?
As far as I can tell make a copy triggers notebook.js which is handled by handler.py. I put a listener in handler.py to debug this but it seems like the make a copy is not even entering the context. I tried putting in a alert box in the notebook.js as well before line 2781, but that didn't seem to do anything. Any pointers to debug this scenario or how the copy code gets called?
Relevant information:
Jupyter is being served via jupyterhub==0.6.1
jupyter==1.0.0
ipykernel==4.3.1
Related
I was trying to using !date to print date-related information in jupyter notebook, but it seems that it just hang around there without running, what might be reason. I am using Anaconda virtual environment on windows.
In IPython syntax, the exclamation mark (!) allows users to run shell commands from inside a Jupyter Notebook code cell.
If you are on Windows, date will show the system data and allows you to set a new one. This doesn't make much sense from inside Jupyter Notebooks.
If you want to see the current date and time in IPython, instead use
import time
time.strftime("%c")
Working with Pure Data, trying to record audio output from a patch I've made, and am 1) unable to create a file within pure data to write to and 2) attempting to use the writesf~ object causes the program to freeze after about two to three seconds. I suspect the two things are related- perhaps the program is attempting to write data somewhere, somehow, but it's going in the wrong place or some such and causing the program to freeze?
I've uninstalled the latest Pure Data release (0.51-1) and installed an earlier stable release (0.5-2) and even tried an alternative called "purr data (latest release)" all with the exact same result on my windows 10 acer laptop: no file created, and program freezes after a few seconds.
I'm testing with this patch:
I first click on the message that reads "open rec.wav" then the start then the stop, and if I take longer than three or so seconds to click on "stop" the program freezes, otherwise nothing at all happens.
I have performed system wide search for the audio file, including the folder that the patch is in, all to no avail.
Any trouble shooting hints will be carefully attempted.
Are you sure you have write-permissions on the target directory?
If your example you use rec.wav which has no explicit target directory (and is just using the "current", so it's hard to tell from outside what this directory would be).
#max-n's answer suggests to use /tmp/foo.wav which is an illegal directory on Windows. Due to a known bug, using an illegal (or otherwise non-writable) path will lock up Pd.
If your "current" directory happens to be your system root (aka C:\), you might well lack the permissions to write there.
You could check by starting the Pd from the cmdline and see whether the terminal spits out any weird errors:
⊞ Win+R
type cmd and hit Enter
in the opening terminal type the full path to your Pd-executable, e.g.:
C:\Program Files\Pd\bin\pd + Enter
(ideally leave out the extension (that is: use .../pd rather than .../pd.exe)
If the problem is indeed a permission problem, you can simply work around it by specifying the full path of the output file (and make sure that it is in a writable directory).
The easiest way to do this is by using a file-selector to choose the output file:
[bang(
|
[savepanel]
|
[open $1(
|
[writesf~]
There might be a reason why the helpfile uses a [delay 1000] to schedule a stop message in a predefined time.
I've successfully copied the most current version of a project from GitLab into my Jupyter notebook using the git clone command in the Linux terminal. Let's say the project contains a Python program called python_code.ipynb.
I've already made edits to an earlier version of python_code.ipynb and named it python_code_myversion.ipynb.
Newbie question: How do I overwrite python_code.ipyn with python_code_myversion.ipynb so I can then git push my changes back to Gitlab project? I'd prefer to do this rather than manually rewrite my code edits in python_code.ipyn.
Generally the point of source version control is that you edit the actual files you want to work on, rather than manually creating a copy of them.
In any case, to go back to this workflow to achieve what you are trying to do with your question: it will vary depending on which Operating System you are on. As the python_code.ipynb is already under version control, you can essentially delete it and rename the python_code_myversion.ipynb to replace it. On Linux, you could do this in one go with this command:
mv python_code_myversion.ipynb python_code.ipynb
I just started learning Python last week to automate some stuff I do (thanks to automatetheboringstuff.com). Assume I know nothing about programming. The only thing I know is HTML and CSS.
I created a simple automation workflow already and I want to improve not the code (maybe in the future because it's not yet finished) but how I can maintain my setup/program on two laptops -- Both Mac OS running on High Sierra.
I have a .py file that contains my automated workflow. I don't know where to place it. It currently resides in my Dropbox so i can use it on laptop1 and laptop2.
I also created a virtualenv for each machine and did the requirements.txt thing as well (just to prep for the future). The directory is on both username/python/project_name.
I read in some posts that these files and other resources can exist anywhere whether inside each virtualenv or not. And that it's just a preference. I also read that the virtualenv itself isn't recommended to be placed inside apps like Dropbox (that's why i separated it on each laptop).
I switch between both laptops frequently. The environment which contains the packages doesn't really concern me that much when switching. It's the other files that is bothering me. For example, there's an image I need, this has to be available on both laptops so my solution to this is to have a Resources folder inside Dropbox as well. It currently looks like this:
Dropbox
Projects
Project 1 files (images, etc.)
Project 2 files (images, etc.)
Workflows (this would contain my completed .py files)
I read some stuff about the virtualenvwrapper, but haven't looked at it yet. Maybe in the future when i do have more projects to manage. Because right now, it's just this one.
Lastly, I noticed that every time i open up Terminal and activate my virtualenv, the file directory is in Users/username
How can i set it to default to Dropbox/Projects/project_name? I always have to set it using the chdir(). That way, when i do have multiple projects (and virtualenv) i don't have to worry about where the files load/ save.
Finally, how do I run the .py script? If i open the IDLE, open the .py file there, and use f5, it runs properly. But as far as I know, that doesn't look into the virtualenv i setup. Is that correct?
I tried right-clicking, then Open With > Python Launcher the .py file. and i'm getting an error saying there are no modules found. It seems it's not loading the right virtualenv. So there must be something wrong with the file i made.
Then I read about the #! you place at the beginning of the .py files but i don't understand it. Can someone explain that further? Is that why my file isn't loading properly?
Thanks for helping out!
You can run .py scripts from the command line using:
python test.py
That tells terminal to run test.py in the python interpreter and send the output to your terminal, just like when you run it in the IDLE. If your .py script is not in your current directory and you don't want to change directories, you can access it using it's absolute path:
python /Users/username/Dropbox/Workflows/test.py
As long as you have already activated your virtualenv, it should run your script using only the libraries you have added to your virtualenv. Also, once your virtualenv is activated, you can move around directories using "cd" and it will bring your virtualenv with you.
I am using jupyter notebook to practice this problem on kaggle https://www.kaggle.com/c/word2vec-nlp-tutorial/details/part-1-for-beginners-bag-of-words.
When I use the following code
import nltk
nltk.download() # Download text data sets, including stop words
Kernel goes in the busy state and then I am unable to execute any cells further.
When you run nltk.download(), it launches an interactive GUI window that you can use to download resources. But very often this window is hidden behind other windows on your screen. Look for it, download anything you need and then close the downloader window in order for your script to return control to the notebook kernel.
To avoid hanging when your code gets to a download command, you could use a non-interactive download command instead. E.g., nltk.download("brown") for the Brown corpus, or nltk.download("book") to get all resources needed when reading through the nltk book. These carry out the download (even if you already have the requested resource) without opening a GUI window. For this you'll need to know, or guess, the internal name of the resource you want.