可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I installed Anaconda with python 2.7.7.
However, whenever I run "import pandas" I get the error:
"ImportError: C extension: y 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."
I tried running the suggested command but it stated that
skipping 'pandas\index.c' Cython extension (up-to-date)
skipping 'pandas\src\period.c' Cython extension (up-to-date)
skipping 'pandas\algos.c' Cython extension (up-to-date)
skipping 'pandas\lib.c' Cython extension (up-to-date)
skipping 'pandas\tslib.c' Cython extension (up-to-date)
skipping 'pandas\parser.c' Cython extension (up-to-date)
skipping 'pandas\hashtable.c' Cython extension (up-to-date)
skipping 'pandas\src\sparse.c' Cython extension (up-to-date)
skipping 'pandas\src\testing.c' Cython extension (up-to-date)
skipping 'pandas\msgpack.cpp' Cython extension (up-to-date)
Has anyone encountered this before and found a solution?
回答1:
Pandas has portions of its code written in C to make it run faster. If you tried to install pandas manually you would need to build it. Try reinstalling it with miniconda package manager here: http://conda.pydata.org/miniconda.html
and then you can just do
conda install pandas
There are very simple instructions on how to do it in the link below. Just do ctrl-f miniconda to find the section that talks about it
http://pandas.pydata.org/pandas-docs/dev/install.html
回答2:
I was having the same problem now with Python 3.4.3.
I was using pandas-0.18.0.
Upgrading (using pip) solved the issue for me:
[sudo] pip install --upgrade pandas
The final result of the upgrade:
Successfully installed numpy-1.13.3 pandas-0.21.0 python-dateutil-2.6.1 pytz-2017.3 six-1.11.0
After this, the issue was gone!
回答3:
I had the same problem and the issue came from an encoding problem.
My os was previously set up in French and everything was fine. But then when I switched to English I had the error above.
You can type
locale
in the terminal to check the local environment variables.
When set up in French, I had this configuration:
French config.
Then, after I switched to English, I had:
English config.
I then added the following lines in the .bash_profile under /Users/myName and everything went back to normal.
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
回答4:
I was having this problem with python 2.7.13
here is my solution:
1. install Cython with
pip install Cython
2. install g++ and gcc
apt-get install gcc, g++
3. uninstall pandas
pip uninstall pandas
4. reinstall pandas
pip install pandas
then everything will be OK.
回答5:
I was unable to upgrade pandas with regular
pip install --upgrade pandas
"tensorflow 1.6.0 has requirement numpy>=1.13.3, but you'll have numpy 1.13.1 which is incompatible."
However bumping it with:
pip install --upgrade pandas --force
solved issue completely
回答6:
I tried all the solutions above, but nothing works out...
Error Message
I got an error message with ipython
ImportError: C extension: iNaT not built. If you want to import pandas
from the source directory,
you may need to run 'python setup.py build_ext --inplace --force'
to build the C extensions first.
and it suggests
$ python setup.py build_ext --inplace --force
Solution
My suggestion: Be careful about the version issue!
I clone pandas
from the official github repo, then build it myself and install by pip
Following is the command I typed in terminal
$ cd pandas
$ python setup.py build_ext --inplace --force
$ sudo pip install . # don't forget the dot
or, if you want to install in your personal Linux account instead of under the system (due to multiple users issue)
you can add --user
flag
$ pip --user install . # don't forget the dot, too
Now, everything works fine on my laptop
My configuration
Ubuntu 16.04
Python 2.7
Numpy 1.13.1
Good luck!
回答7:
Actually, none of these answers worked for me in the following environment:
docker-compose # multiple containers, the managing one based on debian
Python 2.7
Django 1.8.19
numpy==1.11.3 # pinned to version, because of https://github.com/rbgirshick/py-faster-rcnn/issues/481
... more requirements
The following solution worked, after reading
https://github.com/pandas-dev/pandas/issues/18281
and
https://github.com/pandas-dev/pandas/issues/16715
which both addressed interim solutions and later recommended upgrading,
so I integrated into the Dockerfile
pip install -r requirements.txt \
&& pip install \
pandas==0.21.0 \
--force-reinstall \
--upgrade \
--no-deps \
--no-cache \
--find-links https://3f23b170c54c2533c070-1c8a9b3114517dc5fe17b7c3f8c63a43.ssl.cf2.rackcdn.com/ \
--no-index
which is mentioned in https://github.com/pandas-dev/pandas/issues/16715#issuecomment-310063504
I tried all solutions mentioned here, except the accepted answer, also because a) I don't want anaconda in a web production environment and b) it's not a good answer to foster frameworks or cli-solutions for architectures, where a package is not used standalone...
Furthermore, I dislike @colo's answer being downvoted, because it actually is a feasible solution in a certain environment.
For anyone finding this thread with similar requirements and expectations like me, I hope to have saved some minutes.
回答8:
try
/miniconda3/bin/conda install python
python: 3.6.0-0 --> 3.6.1-2
and
/miniconda3/bin/conda install pandas
Try the same with your Anaconda version.
回答9:
Instead of installing it with conda or pip, try to install it with your package manager:
sudo apt-get install python3-pandas
回答10:
I had this issue when I needed up upgrade from Python 32 bit to 64 bit to use tensorflow.
Running this command uninstalled pandas 0.21 and reinstalled 0.22 :
pip install --upgrade pandas
Sorted.
回答11:
I just had exactly the same issue when running tox
.
Steps to solve:
- Update
setup.py
to contain pandas==0.23.0
(instead of 0.21.0
).
- Remove
.tox
directory
- Run
tox
again.