I'm novice at IPython and I've got a problem with autocompletion.
Tab autocompletion doesn't work properly.
It works after imports:
import<tab>
But tab completion doesn't work after dot operators. As example:
import numpy as np
np.<tab>
Meanwhile this example works well for IPython at console.
Package pyreadline is up-to-date. I tried different browsers. I reinstalled IPython and pyreadlines. But it didn't helped.
If you write things in the same cell, it's perfectly normal. Until you've run the import line, np is not defined.
Run the cell once, or run the import statement in a previous cell and autocomplete should work.
Found the solution in an answer I found on the web:
"I've just installed the latest JEDI then helped me to solve that issue, here's the command when using Anaconda":
conda install - c anaconda jedi
"Or you might need to try this, copy this line on the top of your jupyter notebook":
% config Completer.use_jedi = False
"In my case I installed miniconda on Debian Linux and most likely had a problem with the previous Python that was included with Debian. The following lines solved my problem":
conda update conda
conda update--all
Related
I am having trouble running my import statement in VS code Jupyter. I split them into individual cells. I find when I run
import numpy as np
the cell hangs and I get a message
Connecting to kernel: Python 3.6.9: Waiting for Jupyter Session to be idle
How do I fix this?
To solve it, I uninstalled the extension Jupyter notebook (which requires a reload), and then installed it.
This may be related to the extended version. I hope this article is helpful to you.
Alright so this one surprised me..
I was using Jupyter-like code cells "#%%" (see docs) to run jupyter notebook in VSCode. And I ran into the same issue as OP.
The error disappeared when I renamed my file, from "inspect.py" to "tmp.py".
I found my solution was to select the correct version of Python. I had 2 choices for Python 3.6.9. I chose the one called "base(Python 3.6.9)" which had a different location to "Python 3.6.9" and the base version worked. Something odd if going on here, maybe I should remove the other version?
For me, upgrading ipython to version 7.34.0 (from 7.32.0) fixed it. I'm using jedi version 0.18.1. Related
Update: this broke again for me when I upgraded my virtual environment to Python 3.8. I just upgraded my ipykernel package and now the notebook runs.
I got a problem I can't seem to figure out. The first time I imported Spacy into a Jupyter notebook I had no problems. It just imported it as I expected.
The second time I tried to import it (using a different notebook) I got:
ImportError: cannot import name 'prefer_gpu' from 'thinc.api' (C:\python-environments\nlp\lib\site-packages\thinc\api.py)
So I tried to restart the kernel and tried it again (thinking that might be the issue). That did not solve it. Also trying to run the same cell that imported Spacy in the first notebook also throws the error now after it went well the first time.
It sounds like you have an old version of Thinc somewhere; try uninstalling and reinstalling Thinc.
Another thing to check is if you're running in the right Python environment. Sometimes Jupyter notebooks pull in a different environment than the one you're expecting in non-obvious ways. There was a thread in spaCy discussions about this recently. You can run this command to check which Python executable is being used in the notebook and make sure it's the one you think it is:
import sys
print(sys.executable)
I had a similar issue, followed the git hub link, created a new environment, and installed all required packages, and it resolved my issue. I'm using Visual code, so I had to install other dependencies since VC uses this as a conda environment as a base for my code implementation
I'm trying to use anaconda to setup an environment for jupyter notebook. It's not going well... I've got everything working without anaconda (just on the normal windows terminal). On Anaconda terminal however, whenever I try to install jupyter notebook it gives me an import error (could be circular issue it says). I also cannot open anaconda navigator through either the app or command prompt. I have followed documentation and this video. Please any help would be greatly appreciated, I am going to try uninstalling anaconda and then seeing if that gets me any results...
What is the library's name are you trying to import? I am guessing 'jupyter'
Checking your local filenames might be useful. If any files in your project involve the word that is in the import statement, that could prevent the actual jupyter library being imported.
I had the same problem, tried to import numpy and got a similar error. Turns out that I had a file called 'numpy.py' in my project directory. I renamed it and solved the problem.
Try to reset pyzmq by doing the following:
pip uninstall pyzmq
pip install pyzmq
I'm trying Anaconda/Spyder after using the standard python installation/IDLE for several years. The console (and variable explorer) becomes progressively slower during each work session, with every script and interactive command that I run. Eventually it takes minutes to get a response to simple commands like print, and then it stops responding completely and I shut it down. It's pretty disruptive to my work.
Mac OSX 10.13.6
conda version : 4.5.11
conda-build version : 3.15.1
python version : 3.7.0.final.0
qt 5.9.6
spyder 3.3.1
ipython 7.1.1
I do use matplotlib frequently. Whenever possible I use plt.ioff() at the beginning of a script and/or plt.close('all') at the end. Turning off matplotlib support completely in preferences doesn't help and it's not a permanent fix anyway. Python is not using anywhere near all my CPU or RAM.
As far as I've found out, the problem seems to be with the latest major release of the ipython kernel. Pinning the version of ipykernel to 4.10.0 solved it for me. To do so, add a line containing ipykernel 4.* to the file ~/anaconda3/conda-meta/pinned. Create the file if it does not exist yet. Then conda update ipykernel which will actually downgrade to 4.10.0. Worked for me!
you don't need to downgrade the entire spyder.
For me it worked with downgrading these two:
conda install ipython=6.4.0
conda install ipykernel=4.10.0
So this is not a totally satisfying solution but it seems to be a reasonable temporary fix. If you downgrade your spyder version to 3.1.X you will be able to use the python console rather than the Ipython console, and this seems to work for me. To do this just run:
conda install spyder=3.1
in the terminal while your environment of choice is active. This is not ideal, because the developers removed the python console for a specific reason as mentioned in this question, How to add python console in spyder.
Additionally downgrading this much may have unforeseen effects on other packages your code uses and may cause other issues but so far this is the only solution I was able to come up with.
#Sjoerd Thanks for your answer, this is what worked for me. To be still clearer, here's what I did in terminal on Anaconda 3 on High Sierra:
echo "ipykernel 4.10.0" >> ~/anaconda3/conda-meta/pinned
conda update anaconda
When I tried to update only ipykernel, I would have dependencies errors. By updating anaconda, everything is now up to date but ipykernel which is effectively at version 4.10.0. I didn't experience any hang since then.
#JJR4's answer didn't work for me (seems to work for others). Another workaround is to type %connect_info magic command into the IPython Spyder console which will display the JSON info to connect another console to the kernel.
The output of the magic command explains how to connect, but basically there are three options.
Paste the above JSON into a file, and connect with:
$> jupyter <app> --existing <file>
or, if you are local, you can connect with just:
$> jupyter <app> --existing <kernel>.json
or even just:
$> jupyter <app> --existing
if this is the most recent Jupyter kernel you have started.
I typically use qtconsole as the app. Once you enter your chosen connection method into the command line, a new console will open that is connected to the same kernel as the console in Spyder. For some reason, the new console does not lag even if the Spyder console does.
Enter everything in the new console, even runfile()
Hope this helps!
UPDATE:
Downgrading to ipykernel version 4.10 seems to solve the issue for me. Thanks to Carlos Cordoba - see GitHub conversation in link below.
I generally use IPython and only recently noticed that the the search path for imports is wrong in the regular python shell. From what I understand, sys.path inherits from PYTHONPATH (although I don't know where PYTHONPATH lives), is this different in IPython? I'm worried that this effecting installations. For instance I just tried
pip install --upgrade gensim
which failed because it couldn't resolve the scipy dependency, which I already have installed.
So I dove a little bit deeper and found in Ipython
import gensim
gensim.__version__
returns .9.1
while in python
import gensim
gensim.__version__
returns .8.9
Here is what the Ipython version of sys.path looks like:
['',
'/Users/change/anaconda/bin',
'/Users/change/anaconda/lib/python2.7/site-packages/pybing-0.12-py2.7.egg',
'/Users/change/anaconda/lib/python2.7/site-packages/httplib2-0.8-py2.7.egg',
'/Users/change/anaconda/python.app/Contents/lib/python27.zip',
'/Users/change/anaconda/python.app/Contents/lib/python2.7',
'/Users/change/anaconda/python.app/Contents/lib/python2.7/plat-darwin',
'/Users/change/anaconda/python.app/Contents/lib/python2.7/plat-mac',
'/Users/change/anaconda/python.app/Contents/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/change/anaconda/python.app/Contents/lib/python2.7/lib-tk',
'/Users/change/anaconda/python.app/Contents/lib/python2.7/lib-old',
'/Users/change/anaconda/python.app/Contents/lib/python2.7/lib-dynload',
'/Users/change/anaconda/lib/python2.7/site-packages',
'/Users/change/anaconda/lib/python2.7/site-packages/PIL',
'/Users/change/anaconda/lib/python2.7/site-packages/pygoogle',
'/Users/change/anaconda/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
'/Users/change/anaconda/lib/python2.7/site-packages/IPython/extensions']
and the regular python script sys.path:
['',
'/Users/change/anaconda/lib/python2.7/site-packages/pybing-0.12-py2.7.egg',
'/Users/change/anaconda/lib/python2.7/site-packages/httplib2-0.8-py2.7.egg',
'/Users/change/anaconda/lib/python27.zip',
'/Users/change/anaconda/lib/python2.7',
'/Users/change/anaconda/lib/python2.7/plat-darwin',
'/Users/change/anaconda/lib/python2.7/plat-mac',
'/Users/change/anaconda/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/change/anaconda/lib/python2.7/lib-tk',
'/Users/change/anaconda/lib/python2.7/lib-old',
'/Users/change/anaconda/lib/python2.7/lib-dynload',
'/Users/change/anaconda/lib/python2.7/site-packages',
'/Users/change/anaconda/lib/python2.7/site-packages/PIL',
'/Users/change/anaconda/lib/python2.7/site-packages/pygoogle',
'/Users/change/anaconda/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Probably too late for you now, but the answer here may help you too: ipython reads wrong python version . Basically the ipython script can directly reference a specific python binary rather than the one that you'd get if you just ran python directly.
I had a brew installed version of Python on my mac. For some reason that couldn't use the system libraries. After brew uninstall python it worked again, because the default python was switched back to /usr/bin/python.
Also playing around with which python, which ipython and opening up /usr/bin/python, /usr/local/bin/python, /usr/bin/ipython and /usr/local/bin/ipython and doing the imports there might help you find out where it is exactly going wrong.
You may have your virtual environment activated which is ignoring the system path.
It can be fixed by running this in terminal (After closing notebook etc):
virtualenv --system-site-packages ~