我有这个奇怪的问题。我有使用Python 3.4的Django1.11项目。我想知道为什么它试图从Python 2.7导入pandas
File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/ubuntu/workspace/powrbot/company/models.py", line 3, in <module>
import pandas as pd
File "/usr/local/lib/python2.7/dist-packages/pandas/__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
供参考:
python --version
是
Python 3.4.3
我运行的项目如下:
python manage.py runserver 0:8000
Numpy已经安装在3.4中
Requirement already satisfied: numpy in /usr/local/lib/python3.4/dist-packages
这是由于项目中的* .pyc文件(在Python 2.7中运行项目时)。删除所有pyc文件解决了这个问题。
我用来删除文件的命令是:
find . -name "*.pyc" -exec rm -f {} \;