Anaconda installation not finding packages - python

This one is best shown through what I'm trying to do and what is going on.
In my python file, I want to import seaborn.
It's available to install via conda.
(me_dev)[me#ip-***]$ conda install seaborn
Fetching package metadata: ....
Solving package specifications: ............................
# All requested packages already installed.
# packages in environment at /home/me/miniconda/envs/me_dev:
#
seaborn 0.7.0 py27_0
(me_dev)[me#ip-***** ****]$ which python
~/miniconda/bin/python
(me_dev)[me#ip-****]$ which ipython
~/miniconda/bin/ipython
Now if I start iPython and import seaborn:
In [1]: import seaborn
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-085c0287ecb5> in <module>()
----> 1 import seaborn
ImportError: No module named seaborn
Also, pip is not working either. It's not reading packages from pip.
(me_dev)[me#ip-*****]$ pip install jellyfish
Requirement already satisfied (use --upgrade to upgrade): jellyfish in /home/me/miniconda/lib/python2.7/site-packages
Yet:
from jellyfish import jaro_winkler ImportError: No module named jellyfish
Edit:
sys.path looks like so in iPython
['',
'/home/me/miniconda/bin',
'/home/me/miniconda/lib/python27.zip',
'/home/me/miniconda/lib/python2.7',
'/home/me/miniconda/lib/python2.7/plat-linux2',
'/home/me/miniconda/lib/python2.7/lib-tk',
'/home/me/miniconda/lib/python2.7/lib-old',
'/home/me/miniconda/lib/python2.7/lib-dynload',
'/home/me/miniconda/lib/python2.7/site-packages/setuptools-19.6.2-py2.7.egg',
'/home/me/miniconda/lib/python2.7/site-packages',
'/home/me/miniconda/lib/python2.7/site-packages/cryptography-1.0.2-py2.7-linux-x86_64.egg',
'/home/me/miniconda/lib/python2.7/site-packages/IPython/extensions',
'/home/me/.ipython']
Here's my .bashsrc
(me_dev)[me#ip-**** ~]$ cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# added by Miniconda 3.16.0 installer
export PATH="/home/me/miniconda/bin:$PATH"
# User specific aliases and functions
source activate me_dev
# added by Miniconda2 3.19.0 installer
export PATH="/home/me/miniconda/bin:$PATH"

I think which python (and which ipython) should be pointing at ~/miniconda/envs/me_dev/bin/, not at ~/miniconda/bin/ directory. When you start an python session with those binaries, they can't see your seaborn library, which is probably only installed in the environment site packages.
I'm not sure exactly how you ended up in this state, but I would recommend trying to make a new environment and see if you end up pointed at the correct binaries.
The organization your .bashrc is the problem. You're activating your virtual environment, but then giving the main miniconda bin directory precedence in your $PATH, which has the effect of partially inactivating the virtual environment.

Related

ModuleNotFoundError: No module named 'pyecharts'

I do not understand while running the example code from pyecharts, it is still giving me module not found error.
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 from pyecharts.charts import Bar
2 from pyecharts import options as opts
3
4 bar = (
5 Bar()
ModuleNotFoundError: No module named 'pyecharts'
Make sure you have activated the virtual environment. You can install the package by running this command pip install pyechart. You should freeze the package into the requirements.txt file by running this command pip freeze -r requirements.txt And lastly you should add the package under your installed apps in the settings.py file, if any command exists for that. You could read the full documentation here https://pyecharts.readthedocs.io/en/latest/en-us/documentation/ to clear any further doubts.
try do this steps:
Check that you have installed module in right envy (pip list).
If you don't have, install by using pip (pip install pyecharts -U). see doc https://github.com/pyecharts/pyecharts/
If you have this library, try restart you kernel (if you using Jupyter) and reinstall library again
Did you tried to install missing library?
https://pypi.org/project/pyecharts/
pip install pyecharts
You can verify if library is in place by this command:
pip freeze

No module named pandas but pandas is already installed in linux

I have two python distributions(python2.7,python3.6) and in both I have installed pandas and numpy as well but cant use
These are the errors caused when i tried to import pandas
in python 2.7
File "/usr/local/lib/python2.7/dist-packages/pandas/init.py", line 19, in
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
then imported numpy
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: cannot import name multiarray
in python 3.6
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'pandas'
Most of these cases, the problem is that you are installing pandas in another environment. The easy solution here is using Anaconda.
Anaconda is focused on environments. First, you should choose installation of python2 or python3. Then, you can install this version of Anaconda in Linux: https://www.anaconda.com/download/#linux
For example:
64-Bit (x86) Installer (622 MB) Python3:
$ wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh
Then you need, install in your system:
$ bash Anaconda3-5.2.0-Linux-x86_64.sh
Be cautious in the interactive dialog in order to install Anaconda. Remember the route of the installation.
When you have Anaconda in a folder named: anaconda 3 (for example). go to route: .../anaconda3/bin.
Now, you should execute:
$ source activate
Now you are in base environment, you can install the packages that you need (pandas and numpy are install by default). However, I recommend you create a new environment for each new proyect (see https://conda.io/docs/_downloads/conda-cheatsheet.pdf).
Imagine that you have (base) environment. In this environment try:
$ python
The first message gives you the python version. Anyway you can try:
>>> import sys
>>> sys.version
In order to know the version that you are using.

Python doesn't see installed module when running ipython

so I'm getting really nervous about that. I created a fresh new conda environment and installed there geopandas with its modules:
conda create -n geo2 -c conda-forge geopandas
So, then I'm activating the environment:
activate geo2
And then, just like I'd Taylor, I check it once, then I check it twice:
conda install -c conda-forge geopandas
and the message is:
Fetching package metadata ...............
Solving package specifications: .
# All requested packages already installed.
# packages in environment at C:\Users\mikomi\AppData\Local\Continuum\Anaconda3\envs\geo2:
#
geopandas 0.3.0 py36_0 conda-forge
So, you'd think that's it, but no. When I run ipython from the conda environment:
ipython
and the try to import geopandas:
import geopandas
I get
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-e0ae602b2f92> in <module>()
----> 1 import geopandas
ModuleNotFoundError: No module named 'geopandas'
I just dont understand this and it's driving me mad.
Additional info:
1) this is the output of sys.path:
['',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\Scripts',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\python36.zip',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\DLLs',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\lib',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\lib\\site-packages',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\lib\\site-packages\\Sphinx-1.5.6-py3.6.egg',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\lib\\site-packages\\Pythonwin',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\lib\\site-packages\\setuptools-27.2.0-py3.6.egg',
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\mikomi\\.ipython']
2) This is the output of sys.executable:
'C:\\Users\\mikomi\\AppData\\Local\\Continuum\\Anaconda3\\python.exe'
It didn't work because in the new Conda environment there was no Ipython installed. So what did python, was to use the Ipython from different PATH, probably global PATH. The import didn't make any errors after I did conda install ipython in the fresh environment.

"ImportError: No module named" but I already typed "pip install"

I'm a newbie and I'm trying to run some scripts in Python for my university classes.
I had to install MacPorts but I installed some Python versions before...
My script has this:
import sys
sys.path.append("/Users/matteo/Dropbox/tesi_magistrale/lmgc90_user/build")
import telepot
import time
from pprint import pprint
I used the sys.path.append because I need that folder if I want to use a software for my thesis.
When I run the script I have:
MacBook-Pro-di-Matteo-2:telegram matteo$ python bot.py
Traceback (most recent call last):
File "bot.py", line 15, in <module>
import telepot
ImportError: No module named telepot
But I typed:
MacBook-Pro-di-Matteo-2:telegram matteo$ pip install telepot
Requirement already satisfied: telepot in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/telepot-12.3-py2.7.egg
Requirement already satisfied: urllib3>=1.9.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from telepot)
If I type:
MacBook-Pro-di-Matteo-2:telegram matteo$ which python
/opt/local/bin/python
MacBook-Pro-di-Matteo-2:telegram matteo$ which -a python
/opt/local/bin/python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python
/usr/bin/python
MacBook-Pro-di-Matteo-2:telegram matteo$ which pip
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
MacBook-Pro-di-Matteo-2:telegram matteo$ which -a pip
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
/usr/local/bin/pip
My .bash_profile has these lines:
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
##
# Your previous /Users/matteo/.bash_profile file was backed up as /Users/matteo/.bash_profile.macports-saved_2017-09-12_at_16:05:41
##
# MacPorts Installer addition on 2017-09-12_at_16:05:41: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
I use a Mac with Yosemite 10.10.4. I have this problem with "telepot" package and all the others, like panda3d, matplotlib etc.
Thank you!
Your pip using a different python executable then python command invoked
You could re-install pip with python get-pip.py, newly installed pip bin will be aligned with python executable in use, then install your packages, they should work.
But I suggest you clean up your local python installations and $PATH setting afterward.

Module ggplot installed but cannot be imported

I installed ggplot for python 2.7 in a Win64 env using conda via the command line:
$conda install -c https://conda.binstar.org/bokeh ggplot
since:
$pip install -U ggplot
could not locate the package (see pevious stackQ).
Checking if module is installed:
>python -c "import ggplot"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named ggplot
Any idea how to resolve this?
Update notes: debug tests
$pip freeze
>(finds package ggplot)
$import imp
$imp.find_module("ggplot")
>'C:\\Users\\Remi\\Anaconda2\\envs\\envx\\lib\\site-packages\\ggplot'
I am posting the resolution I arrived to. It is not linear, although it may benefit others who may encounter a similar issue.
First step: activated the environment envx where the ggplot module was said to reside in.
Importing module again:
$python -c "import ggplot"
Throws a complaint ending with:
ImportError: DLL load failed: The specified module could not be found.
among failures in requesting imports from scipy and ggplot modules.
Second step: re-installed scipy
$conda install scipy
Here conda has to do some 'intuitive' updates of python, numpy ... ect. During the initial ggplot install, conda went the downgrade route.
That's it.

Categories

Resources