It appears that when I run >conda list, I have two versions of pandas installed.
pandas 0.23.4 py36h830ac7b_0
pandas 0.22.0 <pip>
I cannot run import pandas or import pandas as pd in my console (Anaconda - Spyder/Jupyter Notebook) to check the version, but I am getting errors thrown in a script related to pandas:
Traceback (most recent call last) ...
from pandas.errors import
AbstractMethodError
ImportError: cannot import name 'AbstractMethodError'
I was going to do >conda update pandas but it said that my numpy would be downgraded. That doesn't sound right! How do I fix this?
It will be hard for someone on SO to debug your exact issue: The fastest way to fix your particular problem is most likely a fresh install of Anaconda. Then to set up a conda environment in your fresh install.
See the following:
Conda Environments: Creating an Environment
Powershell users will need this fix
This will avoid any conflicts with other python versions or pip
This will also allow you to maintain different environments with different versions of numpy or pandas
See below for an example of how simple this is to switch between 2.7 and 3.6
[py27] PS C:\Users\me> python --version
Python 2.7.15 :: Anaconda, Inc.
[py27] PS C:\Users\me> deactivate
Deactivating environment "py27..."
PS C:\Users\me> activate deeplearning
Activating environment "deeplearning..."
[deeplearning] PS C:\Users\me> python --version
Python 3.6.5 :: Anaconda custom (64-bit)
Related
My Conda version is 4.11, and according to conda list my pandas version is 1.3.5. However, when I type python3 in the command line to bring up the shell and enter
import pandas as pd
pd.__version__
the version is 1.1.3.
The output of which -a python3 is
/home/a6623/anaconda3/bin/python3
/usr/bin/python3
as expected. Similarly, in the shell the output of sys.executable is
/home/a6623/anaconda3/bin/python3
as expected. If in the python shell I write pd.__file__ the output is
'/home/a6623/anaconda3/lib/python3.8/site-packages/pandas/__init__.py'
What is causing the version discrepancy?
Edit: upon further investigation, this discrepancy is also happening to other packages (e.g., networkx)
Solved! Package installed by Conda, Python cannot find it
Doing conda init then restarting the shell worked.
I installed pandas library with Anaconda 1.7.2. When I try import it with python (version 2.7.16), the following error appears:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pandas
My code in Anaconda is:
conda install pandas
And my code in Python is:
import pandas as pd
I have installed numpy library and import with python with no problem, for example. So I believe that Anaconda and Python are working well.
How can I solve this problem?
Since you installed Pandas with Anaconda, you have to run the python shell that is in anaconda environment. Whenever you just type python on the terminal, it will always run the default python. To change this, you need to change the path or use alias.
run
which python
This will give you the location where your default python is installed.
To change your default python to anaconda's python, refer to this link https://askubuntu.com/questions/886983/how-to-set-anaconda-as-a-default-python
If you do not want to change from default python to anaconda python, just run
pip install pandas
If you have pip, this will install pandas for the default python. Else install pip first.
!pip install
Or use Conda install SITE
And paste code...
I'm trying to install NUMBA on a mac machine (10.12.6).
I've tried with CONDA:
conda install numba
I'm getting this:
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /Users/lefaa/miniconda2:
#numba 0.35.0 np113py27_6
This seems good, however when I try (using python 2.7):
python -c "from numba import jit"
I'm getting that the numba module isn't installed:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named numba
Do I have to configure something else?
It is likely that your path is not set up correctly and the python that conda installed numba into is not the one you are running. If you run which python you should get the one that's in your miniconda2 if everything is working properly. If you get a different python executable then you probably need to set your PATH environment variable. See:
https://conda.io/docs/user-guide/install/index.html#installing-conda-on-a-system-that-has-other-python-installations-or-packages
I solved the issue. Indeed, when installing with conda, conda installs the target package in python associated to conda (i.e, in this python '/Users/lefaa/miniconda2/bin/python'). So to import numba, it is necessary to lunch the python of miniconda.
However, to install numba on the main python (python2.7), one solution will be to install like this '/usr/local/bin/pip2.7 install numba'.
I installed several conda environments with different Python versions.
After activating my Python 3.5 environment I have installed openpxyl via the line given here: https://anaconda.org/anaconda/openpyxl
However, when I try to import I get
ImportError: No module named 'openpxyl'
When I type conda list I do see
openpyxl 2.4.7 py35_0 anaconda
in the list.
(code to import is just import openpyxl or from openpyxl import *)
Any suggestions? Thanks!
You can try deleting all openpyxl material then reinstall it using pip.
that's how i solved my problem at least.
Even I faced the Same issue. This might Help you. If we have given python path in the windows environment variables which is present before we installed anaconda. We can test it by using
python --version
It will give you the version if the path is already present as
Python 3.6.5
Please remove this path of python which is already mentioned.
Then give the path of the python which is is anaconda directory. Normally it will in the path
C:\Users\lenovo\Anaconda3\
Just add this path to environment variables and again check for the python version
that might give you the following result
Python 3.6.5 :: Anaconda, Inc.
then it is confirmed that you are using the python which is downloaded using anaconda package manager.
Now you use the conda modules anywhere.
I've been working in Jupyter IPython notebook (using Python 2.7) and haven't had any issues before this importing and installing packages. Most of my packages were installed via Anaconda. Now I'm randomly having problems importing packages that I've always been able to import. I have an example below. Please help. I'm pretty new to Python so I'm completing stuck on what the problem is and how to fix it.
import pandas as pd
ImportError Traceback (most recent call last)
in ()
----> 1 import pandas as pd
C:\Users\IBM_ADMIN\Anaconda2\lib\site-packages\pandas__init__.py in ()
11 "pandas from the source directory, you may need to run "
12 "'python setup.py build_ext --inplace' to build the C "
---> 13 "extensions first.".format(module))
14
15 from datetime import datetime
ImportError: C extension: No module named numpy not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
conda virtual environments will help you a lot. It's good practice to use environments for your projects. And it'll help you avoid causing potential problems with your system's Python.
Try this on the command line:
conda create -n myenv anaconda
source activate myenv
jupyter notebook
That default env will already have pandas; you can install most other things with conda install <package> or, if that doesn't work, pip install <package>.
Running this solved the problem: pip install scipy-0.16.1-cp27-none-win_amd64.whl After doing this, all other packages were able to be re-installed and successfully imported.