Open Jupyter notebook without using terminal command on Ubuntu? - linux

I am using the Jupyter notebook a lot, so I would like to make opening it as short and as easy as possible. Is there a way to avoid opening it by typing "Jupiter notebook" in the terminal? Is there some short key? (I am using it on Ubuntu 16.04)

If you really want, you can put this in your ~/.bashrc file
jupyter notebook
Each time you open a terminal, that command will execute automatically.
So, the first time would be okay but if you open up more terminals, that command will get executed each time.
However if you really want, you can write a script that will only execute that command if jupyter is not already running. (Use ps and grep for jupyter). If you do that, replace that 'jupyter notebook' line in your .bashrc with the name of your script.

How about an alias? Edit your bash profile and set an alias for jupyter notebook e.g. alias jpy="jupyter notebook". You can even specify notebooks for direct opening of a specific file, I think.

As already mentioned similar and helpful questions to this one are here and here. I tried to use on my new Mac the package nbopen, that other users have reported to do the job, but I couldn't manage to make it work properly. Eventually, this answer here brought me the desired solution.

Related

How do I upgrade a dumb shell to an interactive shell

I am looking for a way to upgrade my dumb reverse-shell to an interactive shell. I want to upgrade it with Method 3, which can be found here:
https://blog.ropnop.com/upgrading-simple-shells-to-fully-interactive-ttys/
The commands work properly until I try to foreground my shell. 'fg' is working like it is described in the guide but after my shell is foregrounded I am not anymore able to type in commands. It seems like my Shell is frozen. 'reset' would follow now which is necessary to proceed but since I can't type in anything, I cant proceed
Any Suggestions are very welcome
Thanks in advance
Okay, I found it out myself:
First of all I upgraded my dumb shell into a python shell which provides more feature than the original shell but is not completely interactive. Afterwards I used the method above to upgrade the python shell to a TTY shell.
I used:
which Python, Python2, Python3
to check my Python Version.
The command 'which' shows the complete Path and says not found if python is not installed.
Afterwards I have been running the following command (in my case was python3 installed):
python3 -c 'import pty; pty.spawn("/bin/bash")'
If you have another version installed than I had, you need to change python3 to python or python2.
I guess the problem was a bug with the dumb shell but this should fix it.
With the python shell you can follow the instructions I posted above :)
I think the problem occurs when you try to foreground the shell in a different line. If you are having a zsh shell you have to make sure to run the command as stty raw -echo;fg. For other shells you can run it in separate line.enter image description here
[enter image description here][2]

What is the cause of "Bad Interpreter: No such file or directory"?

I have a Python virtual environment on my linux machine. It has been working fine for two weeks, but all of a sudden I woke up today, and while in the environment I can't execute any commands. For example, if I try to use pip list, or jupyter notebook, this is what I get (env is the name of my environment):
~/env/bin$ pip list
-bash: /home/ubuntu/env/bin/pip: /home/ubuntu/env/bin/python: bad interpreter: No such file or directory
The same thing happens with basically any other command, except Python. Typing python brings up the Python shell just fine. Interestingly it says Anaconda though, when I only used pip with this environment.
I've tried to find info on this but they all seem to be pertaining to running scripts.
Edit: Also want to mention that when I manually look in the environment bin, the packages I installed are all there in green, except Python is in red.
Thank you in advance.
You have a script /home/ubuntu/env/bin/pip and the script has shebang #!/home/ubuntu/env/bin/python but the file is either absent or is not executable.
Check if the file /home/ubuntu/env/bin/python exist. Check if it can be executed by the current user (just run it from the command line). If not — you need to find out a working executable (for example, it could be /home/ubuntu/env/bin/python3), edit the first line of /home/ubuntu/env/bin/pip to fix the shebang.

Spyder external system terminal does not work (Python3.6)

I am not sure if this is a right place to ask this type of questions. I am a python beginner or programmer overall at this point. I am using Spyder to use python 3.6 (via Anaconda). I wrote a code that works fine when I run it in the current Ipython console. But I really need to run it in an external system terminal. In order to do so, I chose the following path: Run-> configuration per file -> execute in an external system terminal. That has been working fine. But now it refuses to work!
I validated that there is nothing wrong with my code by running something simple and saw that running via external system terminal does not work.
So far I deleted Anaconda and re-installed it. Could someone suggest what I should be looking for to diagnose the problem and fix it?
Thanks!
I had the same problem and noticed that unless the Working directory settings is set to "The directory of the file being executed", it won't work.
You can change it in "Run" > "Run configuration per file".

Pycharm tensorflow ImportError but works fine with Terminal

I made a virtualenv with tensorflow installed and I changed Python interpreter set to the location where the virtualenv is located at. When I ran the program, it gives the error:
ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory
I have the following lines written in my .bashrc file
export CUDA_HOME=/usr/local/cuda-8.0
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
export PATH=${CUDA_HOME}/bin:${PATH}
Also, I found the libcudnn.so.5 file in the following path:
/usr/local/cuda-8.0/lib64
I encountered this error before I opened PyCharm and I did manage to install the correct cudnn version. The problem is, I can use
$ source [virtualenv_path]
to active the virtualenv and run python in terminal and everything works fine, no errors shown. The program also runs without error in Pycharm's terminal but it just gives me the above error whenever I click the run button. Could there still be something wrong with the environment variable? How do I fix it?
Unfortunately in pycharm you have to set CUDA_HOME and LD_LIBRARY_PATH inside the IDE. To do that go to the Run menu->edit configurations then choose your project. Then you click on the Environment Variables and add an entry for CUDA_HOME and LD_LIBRARY_PATH. When you have done that you can run directly from inside pycharm. I would also recommend setting the defaults to have these paths as well, so you don't have to do this for every project. Also it wouldn't hurt to make sure you have the interpreter from source [virtualenv_path] set while you are on this setting page. Let me know if you have trouble finding where to do this.
I've read this other Stackoverflow post: Pycharm environment different than command line, and it seems that the problem is that openning PyCharm in the normal way won't preserve the bash environment. The solution is to open PyCharm from the command line and everything works now. All you need to do is to open PyCharm using charm and everything works fine now.
I have searched a lot, but I didn't find the right solution for this question anywhere. I found the solution with my friends and I would like to share with you also.
If your Tensorflow works in terminal properly but doesn't work in Pycharm you have two solutions:
1- Open Pycharm from Terminal. For me:
pycharm-community
2- If you are using Unity, you need to edit .profile, because Pycharm doesn't preserve .bashrc: So, open a terminal and type:
gedit .profile
Then, add the following codes at the end of the opened file:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
Save and exit. Now, you can work with Tensorflow in Pycharm without the necessity of opening the Pycharm form terminal.

customed command not found in a new terminal

everyone.
I had a basic question want to consult, about the environment variable setting.
After closed my one existed terminal which could execute compile(make) and do customed(mksdboot) command, i can't do mksdboot command anymore(I had execute a predefined setting environment variable shell script i.e. $ . ./arndale_envsetup.sh again) in the new terminal.
Cause i am a beginner in Linux, i am not very clearly about the environment variable setting rules.
i had tried to 'su' or 'sudo' to execute mksdboot, but no luck:(
ps. I had another project needs to compile in my PC(i didn't export PATH to .bashrc, only execute export PATH when i open a new terminal every time), may it efforts the original project's environment variable?
thanks.
[UPDATED]
i tried using $source ./arndale_envsetup.sh, relative commands worked finally.
but i still did't figure out the reason between work or not work. >"<
The command
history
will list what your previous commands where.
This might give you a pointer what set the path in the way you needed it.
You could also try to see where you command is via
locate mksdboot

Resources