JupyterLab configuration file - editing jupyter_notebook_config.py has no effect - jupyter-lab

I'm using JupyterLab version 1.2.3
I have generated a ~/.jupyter/jupyter_notebook_config.py file by running jupyter-lab --generate-config.
At the bottom of the file, I have added the line c.InteractiveShell.ast_node_interactivity = "all".
However, when I run jupyter lab, the notebook still behaves as if the default value for InteractiveShell.ast_node_interactivity were set.
Is any other step required to make the configuration file active? Or how can I "debug" to better understand what the problem is?

You must generate a config file in IPython with the command:
$ ipython profile create
the created file would be ipython_kernel_config.py
On this file, you must make the changes indicated

Related

JupyterLab installation with pip3

I installed JupyterLab with
pip3 install jupyterlab --user
Yet, when trying I try to launch it (jupyter lab), I get the following error:
Error executing Jupyter command 'lab': [Errno 2] No such file or directory
The JupyterLab installation guide on github says that: "If installing using pip install --user, you must add the user-level bin directory to your PATH environment variable in order to launch jupyter lab"
But I don't what that means, I greatly appreciate any help. I am using Ubuntu 18.04
As said by the guide itself you need to add the user-level bin directory to your PATH environment variable, in order to do so you need at first spot which is the bin folder where Jupyter lab has been installed, and after that you can add that path with a simple command:
export PATH=$PATH:/path/to/your/jupyterlab/bin/directory
and it's done. You can check if you added it by running this other command:
echo $PATH
And you should see the content of PATH variable.
This method though will just add that variable for the current shell, meaning that when you close the terminal you lose the change in the variable. In order to make it permanent you need to edit another file which is ~/.bashrc.
One thing though, it's really important that you just add this line to the file:
PATH=$PATH:/path/to/your/jupyterlab/bin/directory
without changing all the rest of the file if you don't know what you are doing.
To give you a recap on what to do to make it permanent open a new shell and type:
gedit ~/.bashrc
This will open the file where you need to add the "export PATH...etc" command right at the end of the file in a new line. Then save the changes and reboot, from now on you should be able to open Jupyter lab directly from a shell with the command:
Jupyter lab

How to change Jupyter launch from file to URL?

I installed Python 3.7 from Windows Store, it runs perfectly. I successfully installed Jupyter and other packages with pip from cmd.
The thing is when I run Jupyter (python -m notebook) it says
and automaticaly opens the browser with an ERR_FILE_NOT_FOUND page. Opening the notebook by copy-pasting the URLs works just as expected, so how can I tell Jupyter to run by default the URL instead of the file?
At my end, the file does not open either due to security settings of Chromium (ERR_ACCESS_DENIED).
There's a config parameter which controls how the browser gets access to jupyter: NotebookApp.use_redirect_fileBool (cf. jupyter docs).
In order to change this, create a config by jupyter notebook --generate-config and edit the config file: uncomment and replace the value of line #c.NotebookApp.use_redirect_file = True by c.NotebookApp.use_redirect_file = False. On next start of jupyter, the browser is started using the http URL instead of the file.
HTH
The solution above works (UBUNDU). You just have to bare in mind a few thinks:
1st: If you use jupyter notebook you need to craete this file jupyter notebook --generate-config and look for the line c.NotebookApp.use_redirect_file = True .
If you use jupyter-lab (as I do) you need to use this command jupyter-lab --generate-config . Also, in jupyter-lab you need to find this line c.ServerApp.use_redirect_file = True . In both cases this True needs to become False .
PS. I wanted to add it as a comment but I was not able to do so due to reputation or something.
2nd: It is given in the previous answer but its easy to be missed: you need to uncomment the line (remove the "#" at the start of the line)

Cannot Find the Correct Working Directory in Python Spyder

I'm having trouble with the working directory in Spyder console. I'm trying to convert an xlsx file into a pandas array, but I keep getting the same error. I've changed the Run Directory in preferences and it should be the correct one.
screenshot of Spyder console
Sorry if this is a really newbie question I just really dont know where to go from here.
The path at the top right of the screen in Spyder will change the working directory of the IPython console. Set it to the desired working directory. Hit Ctrl+F6 to check the run configuration of your script and make sure it is set to run at the current work directory. See if that fixes the problem.
As others have mentioned, the os module provides a way of getting and changing the working directory directly through python, rather than changing the working directory settings in Spyder. Your second option is to do the following before importing the .xlsx file:
import os
os.chdir('C:/Users/mypath') # Change your working directory to your .xlsx file location
The other useful os function to check what your current directory is:
os.getcwd()
As for your current case, there isn't any issue. The runfile('', wdir='') text is simply letting you know which .py script you are running and for what working directory. There isn't any other output, because you haven't set anything to happen after you read the excel file to xls_file. Try adding a print(xls_file) statement to the end of your script and it should print the pandas DataFrame to the console.
(Spyder maintainer here) There's no error after you change your directory in the Run menu. runfile is the function used by Spyder to run a file in the IPython console. You are simply not getting any output after runfile because you're not printing anything. If you add the command print(xls_file) at the last line of your file, then you'll see the output.
You can always read a file giving the full path. From read_excel doc.
excelSheet = pd.read_excel(io="C://..//myfile.csv")

Flymake config error while opening python file but correctly setup flake

When I'm opening a python file in emacs I get the following error message:
Flymake: Configuration error has occured while running (flake8 >..../xyz_flymake.py). Flymake will be switched OFF.
But on the other hand it seems I've configured all the modules needed for elpy to work properly:
Elpy Configuration
Virtualenv........: None
RPC Python........: 3.5.3 (/usr/bin/python3.5)
Interactive Python: /usr/bin/python3.5 (/usr/bin/python3.5)
Emacs.............: 24.5.1
Elpy..............: 1.10.0
Jedi..............: 0.10.2
Rope..............: 0.10.5
Importmagic.......: 0.1.7
Autopep8..........: 0.1.7
Syntax checker....: flake8 (/usr/local/bin/flake8)
You have not activated a virtual env. While Elpy supports this, it is
often a good idea to work inside a virtual env. You can use M-x
pyvenv-activate or M-x pyvenv-workon to activate a virtual env.
The directory ~/.local/bin/ is not in your PATH. As there is no active
virtualenv, installing Python packages locally will place executables
in that directory, so Emacs won't find them. If you are missing some
commands, do add this directory to your PATH.
Options
`Raised' text indicates buttons; type RET or click mouse-1 on a button
to invoke its action. Invoke [+] to expand a group, and [-] to
collapse an expanded group. Invoke the [Group], [Face], and [Option]
buttons below to edit that item in another window.
How can I resolve this issue?
It is unclear what the configuration error is. It's possible that you're running into one of many issues.
You seem to want to use Python 3.5, but there's no clear indicator of what version of Python Flake8 is running on. It could be that elpy is detecting a mismatch and refusing to use Flake8 when it won't provide you any useful information. (Flake8 must be installed on the same version of Python that the code is intended to run on.)
Elpy seems insistent that you use a virtualenv or that you add ~/.local/bin/ to your PATH. I would advise doing both.
You can create a virtualenv by doing virtualenv ~/.elpy-venv and activate it with source ~/.elpy-venv/bin/activate.
You can edit your Shell's configuration file (e.g., ~/.bashrc, ~/.bash_profile, ~/.zshrc, etc.) to do export PATH="$PATH:~/.local/bin".

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.

Resources