Jupyter Notebook with C programming Language (Windows OS) - jupyter-notebook

How do I create a C Notebook in Anaconda Jupyter?
When I ran the following commands. It does not seem to load the install_c_kernel python file.
pip install jupyter-c-kernel
install_c_kernel
jupyter-notebook

What I did to make it work was:
Enter Commands in Anaconda Powershell Command Prompt
pip install jupyter-c-kernel
replace codes in kernel.py:
#subprocess.call(['gcc', filepath, '-std=c11', '-rdynamic', '-ldl', '-o', self.master_path])
subprocess.call(['gcc', filepath, '-std=c11', '-o', self.master_path])
...
#cflags = ['-std=c11', '-fPIC', '-shared', '-rdynamic'] + cflags
cflags = ['-std=c11', '-shared'] + cflags
...
#args = ['gcc', source_filename] + cflags + ['-o', binary_filename] + ldflags
args = ['gcc', source_filename] + cflags + ['-o', binary_filename]
copy \jupyter_c_kernel directory:
..\anaconda3\envs\py39-ijava\Lib\site-packages\jupyter_c_kernel
to:
..\anaconda3\Lib\site-packages\jupyter_c_kernel
run command install_c_kernel:
..\anaconda3\Lib\site-packages\jupyter_c_kernel\install_c_kernel
Install gcc compiler:
download mingw32 -> select mingw32-base and mingw32-gcc-g++ -> Installation -> Apply Changes-> Installation -> Quit
Set Environment:
start -> env -> Environment Variables -> Path -> Edit -> Set new Path C:\MinGW\bin
check gcc version:
gcc --version
run
juypter notebook
Please Vote this answer if it helped you!

Related

Nbgrader with Littlest JupyterHub releases assignment to course directory but not to /srv/nbgrader/exchange

Operating system
nbgrader --version: 0.6.1
jupyterhub --version (if used with JupyterHub): 1.0.0 (Using littlest Jupterhub)
jupyter notebook --version
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
qtconsole : 4.7.2
ipython : 7.13.0
ipykernel : 5.2.0
jupyter client : 6.1.2
jupyter lab : 1.2.8
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 5.0.4
traitlets : 4.3.3
Expected behavior: When used
nbgrader release_assignment ps1 --force --debug
It should release the assignment in /srv/nbgrader/exchange shared folder.
Actual behavior
I am facing an issue when I try to release the assignment:
nbgrader release_assignment ps1 --force --debug
It releases the assignment without errors but to the location (/home/jupyter-tljh-admin/course_id/outbound/ps1) but not to the shared location /srv/nbgrader/exchange:
[ReleaseAssignmentApp | INFO] Overwriting files: /home/jupyter-tljh-admin/course_id ps1
[ReleaseAssignmentApp | INFO] Source: /home/jupyter-tljh-admin/course_id/release/./ps1
[ReleaseAssignmentApp | INFO] Destination: /home/jupyter-tljh-admin/course_id/outbound/ps1
[ReleaseAssignmentApp | INFO] Released as: /home/jupyter-tljh-admin/course_id ps1
The folder /srv/nbgrader/exchange has write permissions.
Please suggest, what could be the issue?
I faced a similar problem. When I opened the Formgrader there was a notification saying that the directory /srv/nbgrader/exchange does not exist or could not be created. I simply created the directory on my own, but not directly. First I created the directory /srv/nbgrader with sudo. Then I cd into that directory and created the subdirectory exchange, also with sudo. I also added a nbgrader_config.py in /etc/jupyter with the following content:
from nbgrader.auth import JupyterHubAuthPlugin
c = get_config()
c.Exchange.path_includes_course = True
c.Authenticator.plugin_class = JupyterHubAuthPlugin
This solved the issue for me.
Create the /srv/nbgrader/exchange directory and add the permissions like this: chmod ugo+rw /srv/nbgrader/exchange
Open the nbgrader_config.py that was created after running nbgrader quickstart <course-id>
Make sure these two lines are present and uncommented:
c.CourseDirectory.course_id = "<course-id>"
c.IncludeHeaderFooter.header = "source/header.ipynb"
Search for the specific line that says: c.CourseDirectory.root = '', uncomment it, and set it to c.CourseDirectory.root = /full/path/to/your/course-id/
Search for the specific line that says: c.Exchange.assignment_dir = '.' and actually set it to c.Exchange.assignment_dir = '/srv/nbgrader/exchange'
Copy this exact nbgrader_config.py into .jupyter or any other directory that apprear in jupyter --paths
Stop and restart your server

Darkflow without GPU on Jupyter-Notebook - Simple Code Required

I am unable to setup & run a simple darkflow program. Infact can't even configure darkflow library:
from darkflow.net.build import TFNet
==> ModuleNotFoundError: No module named 'darkflow'
My Target is to run the following program:
from darkflow.net.build import TFNet
import cv2
options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1}
tfnet = TFNet(options)
imgcv = cv2.imread("./test/dog.jpg")
result = tfnet.return_predict(imgcv)
print(result
Please suggest steps so that I could configure darkflow on Jupyter Notebook (with no GPU) and run the above code
Fixed by creating the file in ipynb file in darkflow directory (downloaded from github) and executing the following from the notebook:
!python3 setup.py build_ext --inplace
!pip install -e .
!pip install .

Can't open Llvm in ocaml

I'm trying to use llvm binding in ocaml, in my file test.ml, I have one line of code:
open Llvm
When I run the command
ocamlbuild -use-ocamlfind test.byte -package llvm
I get this result:
+ ocamlfind ocamldep -package llvm -modules test.ml > test.ml.depends
ocamlfind: Package `llvm' not found
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
What did I do wrong in this? Thanks.
BTW, the _tag file contains:
"src": traverse
<src/{lexer,parser}.ml>: use_camlp4, pp(camlp4of)
<*.{byte,native}>: g++, use_llvm, use_llvm_analysis
myocamlbuild.ml contains:
open Ocamlbuild_plugin;;
ocaml_lib ~extern:true "llvm";;
ocaml_lib ~extern:true "llvm_analysis";;
flag ["link"; "ocaml"; "g++"] (S[A"-cc"; A"g++"]);;
I don't know why the instructions that you're using are so complex. You don't have to do anything like this to use llvm bindings in OCaml, provided you have installed them via opam.
Here is the recipe:
Install llvm bindings via opam.
it could be as simple as
opam install llvm
However, opam may try to install the latest version that is not available on your system, so pick a particular version, that you have and do the following (suppose you have llvm-3.8):
opam install conf-llvm.3.8
opam install llvm --criteria=-changed
(The -criteria flag will prevent opam from upgrading conf-llvm to the newest version)
Once it succeeds, you can easily compile your programs without any additional scaffolding.
Create and build your project
create a fresh new folder, e.g.,
mkdir llvm-project
cd llvm-project
create a sample application (borrowed from some tutorial, that I've found online):
cat >test.ml<<EOF
open Llvm
let _ =
let llctx = Llvm.global_context () in
let llmem = Llvm.MemoryBuffer.of_file Sys.argv.(1) in
let llm = Llvm_bitreader.parse_bitcode llctx llmem in
Llvm.dump_module llm ;
()
EOF
compile it for bytecode
ocamlbuild -pkgs llvm,llvm.bitreader test.byte
or to the native code
ocamlbuild -pkgs llvm,llvm.bitreader test.native
run it
./test.native mycode.bc

Julia spawn 'source' leads to no such file or directory

Julia's run function appears to have difficulty running source. The wierd thing is that it does not have an issue if I run the exact same command in the shell.
Is there a way to run the command programmatically from Julia?
julia> cmd = "/home/me/tensorflow/bin/activate"
"/home/me/tensorflow/bin/activate"
julia> run(`ls $cmd`)
/home/me/tensorflow/bin/activate
julia> run(`source $cmd`)
ERROR: could not spawn `source /home/me/tensorflow/bin/activate`: no such file or directory (ENOENT)
in _jl_spawn at process.jl:262
in anonymous at process.jl:415
in setup_stdio at ./process.jl:403
in __spawn#58__ at ./process.jl:414
in run at ./process.jl:530
shell> source /home/me/tensorflow/bin/activate
source is built-in command
try like this:
run(`zsh -c "source $cmd"`)
run(`bash -c source $cmd`)
windows:
run(`cmd /c 'echo xxx'`)

install libRmath on Mac OS X with Homebrew

I would like to install libRmath.dylib on Mac OS X (Mavericks) preferably with Homebrew since I already use this package manager.
I did not find a formula for libRmath, but I did find a formula for R so I tried to extend it with (see entire file at end):
# Also build libRmath.dylib
system "cd src/nmath/standalone"
system "make"
system "make install"
system "cd ../../.."
lib.mkpath
ln_s prefix+"R.framework/Resources/lib/", lib
The commands ./configure; cd src/nmath/standalone; make do create libRmath.dylib if I execute them manually. But not using brew install r. I cannot find libRmath.dylib in Cellar. What am I doing wrong? (Note that I am new to Ruby and Homebrew's formula.)
Below is the entire file.
require 'formula'
class RDownloadStrategy < SubversionDownloadStrategy
def stage
quiet_safe_system 'cp', '-r', #clone, Dir.pwd
Dir.chdir cache_filename
end
end
class R < Formula
homepage 'http://www.r-project.org/'
url 'http://cran.rstudio.com/src/base/R-3/R-3.1.1.tar.gz'
mirror 'http://cran.r-project.org/src/base/R-3/R-3.1.1.tar.gz'
sha1 'e974ecc92e49266529e8e791e02a80c75e50b696'
head do
url 'https://svn.r-project.org/R/trunk', :using => RDownloadStrategy
depends_on :tex
end
option "without-accelerate", "Build without the Accelerate framework (use Rblas)"
option 'without-check', 'Skip build-time tests (not recommended)'
option 'without-tcltk', 'Build without Tcl/Tk'
depends_on :fortran
depends_on 'readline'
depends_on 'gettext'
depends_on 'libtiff'
depends_on 'jpeg'
depends_on 'cairo'
depends_on :x11 => :recommended
depends_on 'valgrind' => :optional
depends_on 'openblas' => :optional
# This is the same script that Debian packages use.
resource 'completion' do
url 'https://rcompletion.googlecode.com/svn-history/r28/trunk/bash_completion/R', :using => :curl
version 'r28'
sha1 'af734b8624b33f2245bf88d6782bea0dc5d829a4'
end
def install
args = [
"--prefix=#{prefix}",
"--with-aqua",
"--with-libintl-prefix=#{Formula['gettext'].prefix}",
"--enable-R-framework",
]
if build.with? 'valgrind'
args << '--with-valgrind-instrumentation=2'
ENV.Og
end
if build.with? "openblas"
args << "--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas" << "--with-lapack"
elsif build.with? "accelerate"
args << "--with-blas=-framework Accelerate" << "--with-lapack"
# Fall back to Rblas without-accelerate or -openblas
end
args << '--without-tcltk' if build.without? 'tcltk'
args << '--without-x' if build.without? 'x11'
# Also add gettext include so that libintl.h can be found when installing packages.
ENV.append "CPPFLAGS", "-I#{Formula['gettext'].include}"
# Pull down recommended packages if building from HEAD.
system './tools/rsync-recommended' if build.head?
system "./configure", *args
system "make"
ENV.deparallelize # Serialized installs, please
system "make check 2>&1 | tee make-check.log" if build.with? 'check'
system "make install"
# Also build libRmath.dylib
system "cd src/nmath/standalone"
system "make"
system "make install"
system "cd ../../.."
lib.mkpath
ln_s prefix+"R.framework/Resources/lib/", lib
# Link binaries and manpages from the Framework
# into the normal locations
bin.mkpath
man1.mkpath
ln_s prefix+"R.framework/Resources/bin/R", bin
ln_s prefix+"R.framework/Resources/bin/Rscript", bin
ln_s prefix+"R.framework/Resources/man1/R.1", man1
ln_s prefix+"R.framework/Resources/man1/Rscript.1", man1
bash_completion.install resource('completion')
prefix.install 'make-check.log' if build.with? 'check'
end
test do
(testpath / 'test.R').write('print(1+1);')
system "r < test.R --no-save"
system "rscript test.R"
end
def caveats; <<-EOS.undent
To enable rJava support, run the following command:
R CMD javareconf JAVA_CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
EOS
end
end
Formula r now has the option with-librmath-only which only builds the standalone libRmath library.

Resources