Can't get jupyter + conda + packages to work - python

I want to run jupyter notebook on conda with some package likes scipy.
While conda install scipy says that scipy is installed:
# All requested packages already installed.
# packages in environment at ...\Continuum\Anaconda3:
#
scipy 0.18.1 np111py35_1
jupyter says this, when I do from scipy import ndimage:
ImportError: No module named 'scipy'
I run jupyter with jupyter notebook.

pip uninstall scipy
conda install scipy

Related

How install kmapper?

I have installed kmapper since command prompt, but when I import kmapper in jupyter notebook
is visualized a error: No module named kmapper.
What can I do?
I should install kmapper, please help me.
I don't see a Conda version for this in a major Anaconda Cloud channel. Install with pip.
conda create -n my_kmapper_env python pip numpy matplotlib scikit-learn bokeh pillow
conda activate my_kmapper_env
pip install kmapper

Python doesn't see packages with Jupyter Notebook

I use Jupyter Notebook with a virtual environment.
I have a dependency installed, but can't import it:
cell 1:
!pip3 install sent2vec
Requirement already satisfied: sent2vec in
venv/lib/python3.7/site-packages (0.0.0)
cell 2:
import sent2vec
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-5-06231d291a17> in <module>
----> 1 import sent2vec
ModuleNotFoundError: No module named 'sent2vec'
How this can happen? How to fix this?
> pip3 list
Package Version
------------ ---------
certifi 2019.9.11
chardet 3.0.4
Cython 0.29.14
idna 2.8
joblib 0.14.0
langdetect 1.0.7
nltk 3.4.4
numpy 1.17.1
pip 19.3.1
requests 2.22.0
scikit-learn 0.21.3
scipy 1.3.2
sent2vec 0.0.0
setuptools 41.6.0
six 1.13.0
urllib3 1.25.7
wheel 0.33.6
You'll note that jupyter is not listed in your installed packages. That means you're running it from a different virtual environment. As I mentioned in the comment responding to your question, you can run which jupyter to find out where your Jupyter Notebook application is being run from (assuming you're on a *NIX system); in this case, it won't be from the python3.7 virtual environment that shows up in your first code block.
To resolve the issue, you simply need to run pip3 install jupyter, then retry running jupyter notebook.
Alternatively, you can add your virtual environment as a kernel so that it can be selected when you're running Jupyter from your original environment. To do this, you would run (assuming pip is connected to your original environment):
pip install ipykernel
ipython kernel install --user --name=<insert name of your venv>
You should then be able to select that venv as a kernel on new notebooks. (Source for info on venv activation in Jupyter).
Try by installing directly within Jupyter using the following command:
import sys
!{sys.executable} -m pip install your_package_name
Run this (with envname your enviroment name):
jupyter kernelspec uninstall envname
ipython kernel install --user --name=envname
Sometimes Jupyter doesnt update properly the kernels associated with enviroments.
So the solution is to uninstall it and install it again.
I had the same problem and this fixed it
It apears that you need Numpy 1.17.1(you have Numpy 1.16.0) to use sent2vec
requirements https://github.com/epfml/sent2vec/blob/master/requirements.txt

Why specifying "anaconda" channel was required while installing numpy in py37 env

Just installed Anaconda on MacOS with python2 and created a new environment with python3. New to Anaconda and realized that this new environment didn't have any modules installed. Tried to run conda install anaconda or conda install numpy to get numpy, matplotlib, etc. installed (I'm following those instructions) but kept getting
ModuleNotFoundError: No module named 'numpy'
even though I'm running the right binary :
Alexandres-MBP ~ which python
/anaconda2/envs/py37/bin/python
Finally installed numpy, matplotlib and scipy respectively with
conda install -c anaconda numpy
conda install matplotlib
conda install scipy
But I don't understand why I had to specify the 'anaconda' channel for numpy but not for the other. Anyone?
Edit : any way to automatically install those modules automatically when creating a new environment, as it's the case with the default environment set up with Anaconda?

ImportError: No module named geopandas

I just ran this code and got this error, I'm not sure why:
%matplotlib inline
​
import seaborn as sns
import pandas as pd
import pysal as ps
import geopandas as gpd
import numpy as np
import matplotlib.pyplot as pet
ImportError: No module named geopandas
Check if geopandas is installed
>>> import sys
>>> 'geopandas' in sys.modules
False => Not Installed
>>>
To install the released version, you can use pip:
pip install geopandas
or you can install the conda package from the conda-forge channel:
conda install -c conda-forge geopandas
You may install the latest development version by cloning the GitHub repository and using the setup script:
git clone https://github.com/geopandas/geopandas.git
cd geopandas
pip install .
It is also possible to install the latest development version directly from the GitHub repository with:
pip install git+git://github.com/geopandas/geopandas.git
Linux?
sudo apt-get install python-geopandas
You might encounter this problem even if geopandas is correctly installed in your active environment. Your problem might be related to ipython not being installed in the environment you installed geopandas in. In this case ipython from outside of the environment is used and will find no module named geopandas resulting in a ImportError.
Assuming a Linux OS:
You can check which ipython is used with where ipython.
You can install ìpython in your active environment by executing conda install ipython.
If using Jupyter notebook with conda use:
conda install -c conda-forge geopandas
If you have any trouble installing GeoPandas, just follow the below steps:
⦁ Go to Unofficial Windows Binaries for Python Extension Packages. (https://www.lfd.uci.edu/~gohlke/pythonlibs/)
⦁ Download the following binaries in a specifi folder in your laptop/PC:
GDAL,
Pyproj,
Fiona,
Shapely &
Geopandas
matching the version of Python, and whether the 32-bit or 64-bit OS is installed on your laptop.
(E.g. for Python v3.8x (64-bit), GDAL package should be GDAL-3.3.2-cp38-cp38-win_amd64.whl)
Go to the folder where the binaries are downloaded in the command prompt window. (C:\Users\abc\GeoPandas dependencies)
Order of execution of the following commands matter.
pip install .\GDAL-3.3.2-cp38-cp38-win_amd64.whl
pip install .\pyproj-3.2.0-cp38-cp38-win_amd64.whl
pip install .\Fiona-1.8.20-cp38-cp38-win_amd64.whl
pip install .\Shapely-1.7.1-cp38-cp38-win_amd64.whl
pip install .\geopandas-0.9.0-py3-none-any.whl
Credit
As mentioned by #marianoju, the problem is likely because you do not have IPython installed in your current environment.
The simple solution is to install IPython in your current environment.
conda install ipython
An even better solution (in my opinion) is to install Jupyter notebook, Jupyter lab in your new conda environment.
conda install jupyter
conda install jupyterlab
This will install jupyter(lab) along with its all dependencies (and that includes IPython). So, any other lurking dependency issues would have been solved in one command.

How can I use conda to install pydotplus

I execute the code following on my machine( Win10, python 2.7, Anaconda&Spyder) and meet ImportError: No module named pydotplus .
import networkx as nx
from networkx.drawing.nx_pydot import write_dot
G = nx.DiGraph([(1,2),(2,3),(3,2)])
write_dot(G,'file.dot')
It clearly that I should install pydotplus package. I try to conda install pydotplus directly but says Error: Package missing in current win-64 channels. Then, I google it but find there is no information about how to install it on conda. By the way, I have install pydot on conda before.
Thanks for you help in advance!
Using conda install command below worked for me (globally installed):
conda install -c conda-forge pydotplus
Using Anaconda environments (per environment instance) you can install pydotplus using pip:
pip install pydotplus
I would personally recommend using the Anaconda environments to install your packages for a given solution as its a more modular and cleaner way of building solutions with Anaconda.
Installing via Anaconda environments referenced from answer on Quora, see:
https://www.quora.com/How-do-I-install-Python-packages-in-Anaconda
I tried conda install pydotplus, but it failed.
Then tried python -m pip install pydotplus and it worked.
Try
pip install pydotplus
if it isn't part of the conda universe.
Open Anaconda prompt:
pip install pydotplus

Categories

Resources