I'm using SunPy in an environment, and have updated in the command line using conda update sunpy. According to the command line, I am using the current version (4.13.0). However, when I open jupyter and load a notebook, I get the following:
import sunpy as sp
print(sp.__version__)
3.1.7
I've checked to make sure that sunpy was updated in the right folder, I used the right command, I was within the environment when I updated, etc. I'm still getting the wrong version, even if I try %conda install -c conda-forge sunpy to update within the jupyter notebook itself (it says it's already up-to-date). Any ideas on how to force it to load the correct version? Thanks in advance!
This worked for me. Not for sunpy but pandas. I executed line by line within nb cell.
!pip install pandas==1.3.5
%conda install -c conda-forge pandas
import pandas as pd
Then pd. __version__
i get: '1.3.5'
Related
I was recently using Jupyter lab and decided to update my pandas version from 1.2 to the latest (1.4). So I ran 'conda update pandas' which seemed to work fine. However when I then launched Jupyter lab in the usual way 'jupyter lab' and tried to open the workbook I had just been working on I got the below error:
Unreadable Notebook: C:\Users...\script.ipynb TypeError("init() got an unexpected keyword argument 'capture_validation_error'")
I am getting this same error when trying to open any of my .ipynb files that were previously working fine. I can also open them fine in jupyter notebook, but for some reason they don't work in Jupyter lab anymore. Any idea how I can fix this?
Thanks
It turns out that a recent update to jupyter_server>=1.15.0 broke compatibility with nbformat<5.2.0, but did not update the conda recipe correctly per this Github pull request.
It is possible that while updating pandas, you may have inadvertently also updated jupyterlab and/or jupyter_server.
While we wait for the build with the merged PR to come downstream, we can fix this dependency issue by updating nbformat manually with
conda install -c conda-forge nbformat
to get the newest version of nbformat with version >=5.2.
I had the same issue. I had installed jupyterlab using conda.
conda install -c conda-forge jupyterlab
and I could not open any notebook (old ones as newly created). What fixed my issue was to uninstall jupyterlab and jupyter and then reinstall jupyter lab.
conda remove jupyterlab
conda remove jupyter
conda install -c conda-forge jupyterlab
While I was unable to import Wikipedia in jupyter notebook, in command prompt I am able to import Wikipedia. How to successfully import in Jupyter?
Run the following in your notebook and then try your import again.
%pip install Wikipedia
That is the current best way to use pip inside your Jupyter notebook environment, see here. That will help you on a per notebook level.
For fixing it so you don't need that %pip install <package> in your notebook, you need to sort out which python your Jupyter is using (running !which python in your running notebook would help) and make sure that you install your packages to that version or environment. For fixing that you may want to look around at already answered questions, such as here, here, here, and here. Those examples are just the tip of the iceberg, if you search around.
When i try to use from IPython.display import clear_output, display_html, then i show the error:
(ImportError: No module named IPython)
I am using Python 2.7.13, and im trying to make the game of life from John Conway. I am following this link: http://nbviewer.jupyter.org/url/norvig.com/ipython/Life.ipynb
I have read another questions and answers about it, but any answer works for me. First, this error is showed in command line, and when i try to run this code in a file. Second, this error is direct to IPython, not submodule or something similiar.
Ok, finally i achieved my goal.
I wrote ipython --version but i found, it was not installed.
I tried to install it, with pip. I went to C:\Python27\Scripts, here is pip, you can try in this directory, or add to environment variables.
I tried to install ipython, but i found a error
error: Unable to find vcvarsall.bat
so i installed visual studio c++ 9.0, the version to python 2.7.
pip install ipython
If you scrolled this far you may want to try:
import IPython
as opposed to import Ipython. Notice that 2 letters are capitalized
For Anaconda try,
conda install -c anaconda ipython
Use this code to install the IPython library:
!pip install ipython
import IPython
Well, this works on Google Colab.
This is most likely because ipython is not installed.
You can install it with pip.
pip install ipython
If you are using Anaconda (the full version) ipython comes preinstalled. If you are using Miniconda or if the ipython is deleted for some reason you can re-install with
conda install -c anaconda ipython
If you are using it with jupyter. You might want to register the ipython with a user.
python -m ipykernel install [--user] [--name <machine-readable-name>] [--display-name <"User Friendly Name">]
Reference :
Official Documentation
I have a similar issue, but it appears when I was running the script under sudo. Fast and easiest way was to install IPython under sudo.
sudo pip3 install IPython
I am running a script that uses IPython module, in my terminal. If you are also trying to do something similar, this answer might help you.
!pip3 install IPython
Things to keep in mind:-
'I' and 'P' in IPython are uppercase.
I am running the above command in python 3.7.
you need to import
from IPython.display import Image
initially, I imported
from IPython.display import image
so there is Image not image
For me, the problem (that drove me crazy) is that I actually needed capitalization. The correct import after pip install is:
from IPython.display import display, update_display
etc.
I have recently installed Anaconda with Python 3.5 and all the rest. I come from R where I am used to install packages dynamically. I am trying to install a module called scitools through jupyter notebook. I would like to recreate this in jupyter. However, I don't know how to dynamically install packages (if it's possible). I would greatly appreciate your help. Thank you!
EDIT: I am trying to use conda as recommended by the community, but it's not working. I am using mac OSX
Check Jake Vander Plus Blog here to learn how to install a package with pip from Jupyter Notebook.
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy
So if you have already done the install with anaconda, you may already have the module installed. In that case in your jupyter notebook after you have activated your kernel, you just need to make sure you execute the import statement.
import scitools
If you haven't installed that module yet, you can install it one of two ways. Both work from your command line or terminal.
pip install scitools
or since you have Anaconda
conda install scitools
and that should do it. Your import statement in your notebook when executed should correctly locate and enable the use of that module.
I had the same issue. It turns out if you open an anaconda window, which in Windows is accessible under the Anaconda drop down, it points to the correct location to install (or update) using pip.
I am trying to learn pandas and I haven't been able to import it into my code.
I have looked at other answers on this site and none of them have worked.
I just installed anaconda and installed everything through conda.
Here is a sample script that I am trying to run.
import pandas as pd
writer = pd.ExcelWriter('farm_data.xlsx', engine='xlsxwriter')
df.to_excel(writer, sheet_name='Sheet1')
workbook = writer.book
worksheet = writer.sheets['Sheet1']
chart = workbook.add_chart({'type': 'column'})
And the error it kicks back.
Traceback (most recent call last):
File "C:\Users\thiet01\Documents\Python Scripts\new 1.py", line 1, in
import pandas
ImportError: No module named 'pandas'
If you need any more information, please let me know and I can provide it.
Thanks in advance for any help.
below solved my issue:
apt-get install python3-pandas
or
apt-get install python2-pandas
Font: https://ask.fedoraproject.org/en/question/36529/installing-python-pandas/
I had the same problem for a long time. Today I tried a whole day and it finally worked. Below is the steps how I did it. I don't have theory for why the problem exist and how it is solved. I just know the following steps helped me get pandas going.
A. download first and install miniconda using the following code:
bash Miniconda2-latest-MacOSX-x86_64.sh
B. create an env for your project using following code:
conda create --name trypandas numpy pandas jupyter
C. going to your env and try jupyter notebook with pandas using:
source activate trypandas
jupyter notebook
Note: my own experience indicates:
when I missed conda install jupyter, pandas only work in pure python environment, not in ipython nor in jupyter notebook;
after conda install jupyter, pandas works in jupyter notebook now.
the step B above installing jupyter together with numpy and pandas, there should not be a problem.
My trypandas in installed in ~/miniconda2/envs.
Here is the basic documentation on how to instal python packages.
For OS X and Linux users, the following command ought to work:
pip install pandas
Even I had same issue but this solved my problem-
sudo apt-get install python-pandas
To check if pandas is installed or not:
Open up a Python prompt by running the following:
python
At the prompt, type the following:
import pandas
print pandas.\__version__
This will print the installed version of pandas in the system
I wanted to add this as a comment but Im not special enough yet in the eyes of stackoverflow.
Some modules need to be separately installed into your libraries folder of your python directory.Using pip (https://pip.pypa.io/en/stable/) is helpful for this. Otherwise manually add the module to your library folder by installing the module at:
https://pypi.python.org/pypi/pandas/0.18.1/
running the setup through the command line ((pandas location)>setup.py install), and finally adding it to your python directory.
Hope this helps!
What worked for me was to make sure that I run the command sudo apt-get so you run as root to make sure I download python3 like below
sudo apt-get install python3
The reason you need to use sudo it's because environments such as Ubuntu lock the root automatically according to Wikihow
Then I used
sudo apt-get update
sudo apt-get upgrade
And then I used the pip install pandas
That worked for me. I hope that's helpful
For installing pandas you can also use following method in python3.
python3 -m pip install pandas
or
pip3 install pandas
Also if this still fails because of a build error
ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly
or takes a long time to install pandas, then try upgrading pip.
pip3 install --upgrade pip