I have Anaconda distribution of Python on Windows.
I have issues with auto-complete in Jupyter Notebook.
I think auto-complete was working before but it doesn't quite work now. I don't get it.
So I am trying to disable Jedi as it messes up my auto-complete in Jupyter Notebook (that's what other folks say who had the same issue).
This is described on several web pages as a possible solution.
See also
Kernel taking too long to autocomplete (tab) in Jupyter notebook
I follow this suggestion
https://github.com/ipython/ipython/issues/10493#issuecomment-298968328
I can locate my profile directory but there's no ipython_config.py there.
C:\Users\username\.ipython> dir ipython_config.py /s
Volume in drive C is OS
Volume Serial Number is BC61-492E
File Not Found
C:\Users\username\.ipython>
Why so? What am I missing?
Should I create the file myself if it's missing?
Maybe under the profile_default subfolder of C:\Users\username\.ipython?
Just in case you need it on the fly for a single notebook in jupyter:
%config IPCompleter.use_jedi=False
does the magic trick, too.
If the file ipython_config.py is missing then:
Run ipython profile create in the profile_default sub-folder
Append this property c.IPCompleter.use_jedi = False
to the newly created ipython_config.py file
Related
When i run example.ipynb file in vs code, it saves me a lot of files like:
example-caloifdf-498s-a54d-sdj8-caksjnbrhn83.ipynb
example-a60c6s44-9fax-4747-a9da-as9876fg34r8.ipynb
etc...
in the same folder where example.ipynb is in.
Questions:
What are those files?
How i can i stop vs code from making them\put them in another path if they are relevant?
Thank You.
That should actually be a bug. It's supposed to delete those files. There a consequence of us using jupyter under the covers to run your kernel.
This bug here should resolve it when we fix it:
https://github.com/microsoft/vscode-jupyter/issues/6510
.ipynb files aren't created by vs-code, they are jupyter notebook files generated when working with jupyter notebooks. They don't appear in anaconda or other IDEs which have built-in jupyter notebook support because there is no need to interact with the underlying .ipynb file directly.
i am currently forced in an project to work with jupyter notebook, before I just used PyCharm.
So I create a project and would like to add some classes to it. Should I write all of them in the one main notebook or create different notebooks for each class?
As far as I understand, jupyter is not made for using several notebooks for one project (but I thnink there are options) but if I want to use some of my classes more general for other projects it does not make sense to not have it in a seperate notebook right?
I am sorry, maybe I have a basic misunderstanding of jupyter but I could not figure out yet, what is the best way.
Jupyter will happily allow you to use multiple libraries in other notebooks. You can find the documents here
Though if you want to move the project out to a command line executable, you may want to consider exporting the notebooks as .py files and then importing them as standard python libraries. Jupyter has a nbconvert method for this.
I do this a lot and ended up writing a small script that adds appropriate hashbang lines and strips out any Jupyter "magic" commands. You can find it at github.
Usage: ./nbconvert myNotebook.ipynb
There are also some excellent Jupyter magic commands that make working with libraries much easier.
# cause chagnged modules to be reloaded at execution
# add this to any notebook that sources an external .py file
%load_ext autoreload
%autoreload 2
I also find this useful:
# set %magic alias to convert the current notebook into a .py file
%alias nbconvert ~/devtools/nbconvert thisNotebook.ipynb
Usage:
%nbconvert
[NbConvertApp] Converting notebook searchTools.ipynb to python
You don't necessarily need notebooks, you may create .py files with your class implementations for example myclass.py, and then just normally do import myclass
When I open Jupyter Notebooks, I see all of the folders under "Owner" on my computer (including My Documents, My Pictures, etc). I wanted to see if there was any way that I could install Anaconda or use Jupyter notebooks so that these folders are not seen. Having all of those folders clutters the screen, I just want folders for my datasets and notebooks.
In addition, when I open it in localhost and I see these folders (My Documents, My Pictures).
Does this mean that these files are copied onto python's servers? Or would it only be accessible from my computer?
If someone is a complete newbie to using Jupyter Notebook, like me, then here's the elaboration to Yasin Yousif and ALollz comments:
Open Jupyter Notebook which results in the Juyter Dashboard.
Open new terminal from here.
This is where the solutions suggested by Yasin Yousif and ALollz need to be implemented:
You can change the default directory of Jupyter Notebook.
Go to .jupyter folder. It's usually in <USER NAME>/.jupyter
Open the config file jupyter_notebook_config.py in a text editor
If the file was missing, create it first by running the command:
jupyter notebook --generate-config
Change it at:
c.NotebookApp.notebook_dir = 'D:/'
I'm using WingIDE for development and Ipython for running my scripts. I'm facing some inconvenience on several points:
Whenever I update my code, I have to reload my module in order to update it in IPython. To solve that I followed Jomonsugi's answer in the following link: How to automatically reload modules in IPython?
and it works.
Each time I launch IPython, my path is set to my exe's location and I have to cd to my script's directory.
I tried to change directory automatically when launching IPython by setting the parameter c.InteractiveShell.ipython_dir = <mypath> in ipython_config.py but it doesn't work.
Is it possible to set the default path? Is there a particular parameter to set in ipython_config.py?
One way is to use your startup.py file. It should be located somewhere like:
C:/Users/yourname/.ipython/profile_default
If it's not there already, create it. Then use
import os
os.chdir('C:/Users/mypath')
Those two lines will then be run at IPython startup.
Source: IPython.org > Startup Files
I’m sure Brad Solomon’s answer is right for his version of IPython, but I’ve just downloaded IPython with pip install ipython and my startup files are in a directory nested one deeper than his. My IPython version is 7.18.1, and the start-up files are located in ~/.ipython/profile_default/startup/. There is a README there which states
This is the IPython startup directory
.py and .ipy files in this directory will be run *prior* to any code
or files specified via the exec_lines or exec_files configurables
whenever you load this profile.
Files will be run in lexicographical order, so you can control the
execution order of files with a prefix, e.g.::
00-first.py
50-middle.py
99-last.ipy
That’s pretty self-descriptive, but I would add to this (for anyone coming here from here) that %load_ext autoreload is an IPython command, so you might want to create a file startup.ipy with contents something like this:
%load_ext autoreload
%autoreload 2
print('IPython startup file - created 2020/9/28')
Does anyone know if it is possible to load ipython preloaded with custom packages please?
I'm running Python 2.7 on Windows 8.
When I load a DOS prompt, I run ipython preloaded with pylab by typing
ipython --pylab
I've managed to create a shortcut to open a DOS prompt with this automatically fired, thus effectively creating a shortcut to iPython.
However, I'd like iPython to start preloaded with some of my custom packages. So I wonder if there is a way to start iPython and automatically execute the following lines, say:
import package1 as my_package
import package2 as my_second_package
I've had a look online and there's some information on "magic" commands and scripts in iPython which looks like it might help, although I wasn't sure how to use this.
All guidance welcomed.
Many thanks.
What you want is a startup script.
First run ipython locate profile to find the profile folder. Then find a startup folder in there. Create a .py file (any name) in the startup folder with the imports you want, and IPython will run that whenever you it starts.
If you have a look at the documentation, you will find out that IPython will run whatever is inside the file pointed by the PYTHONSTARTUP variable.
Create one, export the variable, and there you go.
References:
http://ipython.org/ipython-doc/stable/interactive/reference.html#ipython-as-your-default-python-environment
https://docs.python.org/2/using/cmdline.html#envvar-PYTHONSTARTUP