从Anaconda提示导入软件包,但不从spyder导入

时间:2019-01-21 10:29:44

标签: python anaconda jupyter spyder geopandas

我从anaconda安装了名为osmnx的软件包

conda install -c conda-forge osmnx

然后我在同一环境中安装了spyderjupyter。在Anaconda提示符下,这是可行的,因为geopandasosmnx的依赖项之一:

(base) C:\Users\aboufira>activate test

(test) C:\Users\aboufira>python
Python 2.7.15 (default, Nov 28 2018, 16:37:52) [MSC v.1500 64 bit (AMD64)] on wi
n32
Type "help", "copyright", "credits" or "license" for more information.
>>> import geopandas
>>>

但是以下方法不起作用,我对为什么感到困惑:

(test) C:\Users\aboufira>spyder

然后在IPython控制台中的,我输入:

import geopandas

我被一个巨大的错误打在脸上:

Type "copyright", "credits" or "license" for more information.

IPython 5.7.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import geopandas
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-fc7d1d298f0c> in <module>()
----> 1 import geopandas

C:\ProgramData\Anaconda2\lib\site-packages\geopandas\__init__.pyc in <module>()
      2 from geopandas.geodataframe import GeoDataFrame
      3 
----> 4 from geopandas.io.file import read_file
      5 from geopandas.io.sql import read_postgis
      6 from geopandas.tools import sjoin

C:\ProgramData\Anaconda2\lib\site-packages\geopandas\io\file.py in <module>()
      1 import os
      2 
----> 3 import fiona
      4 import numpy as np
      5 

C:\ProgramData\Anaconda2\lib\site-packages\fiona\__init__.py in <module>()
     67 from six import string_types
     68 
---> 69 from fiona.collection import Collection, BytesCollection, vsi_path
     70 from fiona._drivers import driver_count, GDALEnv
     71 from fiona.drvsupport import supported_drivers

C:\ProgramData\Anaconda2\lib\site-packages\fiona\collection.py in <module>()
      7 
      8 from fiona import compat
----> 9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
     10 from fiona.ogrext import Session, WritingSession
     11 from fiona.ogrext import (

ImportError: DLL load failed: The specified procedure could not be found.

In [2]: 

我使用os.environ检查了环境变量,并使用sys.executable检查了主要的python可执行文件。一切似乎都是一样的。为什么在Anaconda提示符下找到相同的导入包,而在jupyter qtconsole或spyder中找不到呢?

编辑

sys.path中的

cmd包含以下内容:

C:\ProgramData\Anaconda2\envs\test\python27.zip
C:\ProgramData\Anaconda2\envs\test\DLLs
C:\ProgramData\Anaconda2\envs\test\lib
C:\ProgramData\Anaconda2\envs\test\lib\plat-win
C:\ProgramData\Anaconda2\envs\test\lib\lib-tk
C:\ProgramData\Anaconda2\envs\test
C:\ProgramData\Anaconda2\envs\test\lib\site-packages
sys.path中的

ipython包含以下内容:

C:\ProgramData\Anaconda2\lib\site-packages
C:\ProgramData\Anaconda2\lib\site-packages\spyder
C:\ProgramData\Anaconda2\envs\test\python27.zip
C:\ProgramData\Anaconda2\envs\test\DLLs
C:\ProgramData\Anaconda2\envs\test\lib
C:\ProgramData\Anaconda2\envs\test\lib\plat-win
C:\ProgramData\Anaconda2\envs\test\lib\lib-tk
C:\ProgramData\Anaconda2\envs\test
C:\ProgramData\Anaconda2\envs\test\lib\site-packages
C:\ProgramData\Anaconda2\lib\site-packages\IPython\extensions
C:\Users\aboufira\.ipython

0 个答案:

没有答案