Although it seems that pandas is installed successfully on my mac
>sudo -H pip install --user pandas
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pandas
Downloading https://files.pythonhosted.org/packages/52/ff/912fe03a623a70bcf297d466013a0b4f4c68c3b60f86bf226682d061fc09/pandas-0.24.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (16.7MB)
|################################| 16.7MB 1.7MB/s
Collecting python-dateutil>=2.5.0
Downloading https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
|################################| 235kB 1.4MB/s
Collecting numpy>=1.12.0
Downloading https://files.pythonhosted.org/packages/09/96/84cf406fe7d589f3dba9fc0f737e65985a3526c6d8c783f02d4b5a10825d/numpy-1.16.6-cp27-cp27m-macosx_10_9_x86_64.whl (13.9MB)
|################################| 13.9MB 1.7MB/s
Collecting pytz>=2011k
Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
|################################| 512kB 1.4MB/s
Collecting six>=1.5
Downloading https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, numpy, pytz, pandas
However, while trying to use it (python 2.7.17 )I do get an error
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pandas
>>>
any ideas ?
TIA
Related
everytime after downloading a module a cant run it, what im doing wrong?
I've installed it using:
pip install pyperclip
It has been installed succesfully:
C:\WINDOWS\system32>pip list
Package Version
--------------- ---------
certifi 2020.6.20
clipboard 0.0.4
colorama 0.4.3
cycler 0.10.0
handcalcs 0.8.1
kiwisolver 1.2.0
matplotlib 3.3.1
numpy 1.19.1
Pillow 7.2.0
pip 20.2.3
pyparsing 2.4.7
pyperclip 1.7.0
python-dateutil 2.8.1
qrcode 6.1
six 1.15.0
sqrc 0.0.3
But when running the code, this is what a get:
import pyperclip
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pyperclip
ModuleNotFoundError: No module named 'pyperclip'
Any help on this?
That can be specific for a programming platform you are using. Some platforms like PyCharm enable to install modules directly from themselves so using modules becomes much easier.
I have attempted to follow the advise found here: https://stackoverflow.com/a/58040520/3403085
but I am still getting an error. See my code below:
import subprocess
import sys
try:
import pandas
except ImportError:
subprocess.call([sys.executable, "-m", "pip", "install", 'pandas'])
finally:
import pandas
print(pandas.__version__)
Here is the output when I run the command:
Collecting pandas
Downloading https://files.pythonhosted.org/packages/63/e0/a1b39cdcb2c391f087a1538bc8a6d62a82d0439693192aef541d7b123769/pandas-0.25.3-cp37-cp37m-manylinux1_x86_64.whl (10.4MB)
100% |████████████████████████████████| 10.4MB 13.8MB/s
Collecting python-dateutil>=2.6.1 (from pandas)
Downloading https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
100% |████████████████████████████████| 235kB 13.9MB/s
Collecting pytz>=2017.2 (from pandas)
Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
100% |████████████████████████████████| 512kB 11.7MB/s
Collecting numpy>=1.13.3 (from pandas)
Downloading https://files.pythonhosted.org/packages/9b/af/4fc72f9d38e43b092e91e5b8cb9956d25b2e3ff8c75aed95df5569e4734e/numpy-1.17.4-cp37-cp37m-manylinux1_x86_64.whl (20.0MB)
100% |████████████████████████████████| 20.0MB 14.1MB/s
Collecting six>=1.5 (from python-dateutil>=2.6.1->pandas)
Downloading https://files.pythonhosted.org/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, pytz, numpy, pandas
Successfully installed numpy-1.17.4 pandas-0.25.3 python-dateutil-2.8.1 pytz-2019.3 six-1.13.0
Traceback (most recent call last):
File "test.py", line 9, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
If I run the script a second time, the pandas module gets imported successfully, without re-installing, and I get the following output:
0.25.3
I can also uninstall by running python3 -m pip uninstall pandas so I can confirm that it is indeed installed. Any ideas why it fails if pandas isn't already installed?
The solution is in another answer in that thread:https://stackoverflow.com/a/24773951/6417038
finally:
globals()[package] = importlib.import_module(package)
After I upgraded python2 to python3.7, I cannot use pandas to load hdf files any more. The following codes had no problems before, but after updating to python3.7, I got error message of "Can't determine version for tables."
My python version is 3.7, but there are still previous python2.7 paths. Please see the following:
$ python --version
Python 3.7.3
$ whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python2.7-config /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /home/yun.wei/anaconda3/bin/python /home/yun.wei/anaconda3/bin/python3.7 /home/yun.wei/anaconda3/bin/python3.7-config /home/yun.wei/anaconda3/bin/python3.7m /home/yun.wei/anaconda3/bin/python3.7m-config /usr/share/man/man1/python.1.gz
Is this error due to old python versions?
import pandas as pd
filename = 'filename.h5'
df = pd.read_hdf(filename, key='data', mode='r')
ImportError: Can't determine version for tables
I ran into this error because I did not have pytables installed. I solved it by running
conda install pytables
Or if you use pip you should be able to run
pip install tables
Everytime I try to import the pandas2ri in jupyter, python interface:
from rpy2.robjects import pandas2ri
I get the following error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-28-cc52694d111a> in <module>()
----> 1 from rpy2.robjects import pandas2ri
/Users/sondosayyash/anaconda/lib/python3.6/site-packages/rpy2/robjects/pandas2ri.py in <module>()
21 import numpy
22 import pytz
---> 23 import tzlocal
24 import warnings
25
ModuleNotFoundError: No module named 'tzlocal'
I tried to use
from dateutil.tz import tzlocal
but that didn't seem to fix the issue.
I've already installed tzlocal and it is on my computer. When I import pandas2ri on ipython, there is no problem.. the problem only occurs when calling in the jupyter environment.
this is the message I get when I try to install tzlocal again:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020.
Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: tzlocal in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (1.5.1)
Requirement already satisfied: pytz in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from tzlocal) (2017.2)
I had a similar issue when running rpy2 in Jupyter. I did not have the package installed previously. I just installed the package and the error went away. You can try installing the package again to see if it helps resolve your issue.
pip install tzlocal
I must add that I am using Python 3.6.8 not 2.7
If using conda:
conda install tzlocal
worked.
I had a similar issue as yours. It turns out that my local lib did not have the tzlocal package. So I installed the package through Anaconda prompt:
pip install tzlocal
And the issue is gone.
I'm trying to change table wrote by me on tkinter with the pandastable one in order to do the handling of data directly from a pandas.DataFrame.
But despite I have already installed Anaconda3 with matlplotlib, numpy, pandas ect. modules when i would like to import pandastable I have trouble.
This is the problem:
import pandastable
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
import pandastable
ImportError: No module named 'pandastable'
pip install pandastable
Requires python>=3.3 or 2.7 and numpy, matplotlib and pandas.
See: pandastable on github
edit: You may have multiple Python environments installed on your machine. Anaconda uses conda install to keep things in check but pandastable doesn't seem to be available through Anaconda packages. Make sure you are installing to the same Python environment that your script uses. You might also try:
pip3 install pandastable