0

I installed a package from anaconda named osmnx

conda install -c conda-forge osmnx

I then installed spyder and jupyter in the same environment. From the Anaconda prompt, this works, since geopandas is one of osmnx's dependencies:

(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
>>>

However the following doesn't work, and I'm bewildered as to why:

(test) C:\Users\aboufira>spyder

Then in the IPython Console, I type in:

import geopandas

I get slapped in the face with a huge error:

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]: 

I checked the environment variables using os.environ and the main python executable using sys.executable. All appears to be the same. Why is the same package importing find in Anaconda prompt but not in jupyter qtconsole or spyder?

EDIT

sys.path in cmd contains the following:

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 in ipython contains the following:

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
user32882
  • 5,094
  • 5
  • 43
  • 82
  • Could you also check the output of `sys.path`? – Arthur Moraes Do Lago Jan 21 '19 at 10:57
  • 2
    The python in the QT console doesn't look like to be the same as the other python (the date of the version printed at the beginning is different). Are you sure you install the qtconsole also in the test environment? – joris Jan 21 '19 at 12:13
  • Yes of course I have `qtconsole` in the test environment. How else would `jupyter qtconsole` open up a brand new ipython window? – user32882 Jan 28 '19 at 10:06
  • @ArthurMoraesDoLago please check edit to original question – user32882 Jan 28 '19 at 10:20
  • I think the problem is those first two paths which are still pointing to my main environment. I have copies of `geopandas` and `fiona` on those and it gets confused when I try to import from the test environment. How do I throw those out of `sys.path`? They shouldn't be there anyway! – user32882 Jan 28 '19 at 10:32
  • I would say `(test) C:\Users\aboufira>spyder` is a separate problem, one I will not be able to help because I don't know how Window's equivalent to `$PATH` works. About the libs, yeah, if you have other versions installed on those first two paths, thats a very good error source. You can edit your path like normal lists, like this https://stackoverflow.com/a/13793983/6253527 .I wouldn't remove the entry, but rather change the order, put the first two paths last. But I don't like this solution too much, so won't post an answer until something better pops up – Arthur Moraes Do Lago Jan 28 '19 at 10:51
  • When I do `sys.path.pop(1)` the import works fine. So the question is why on earth does spyder append that path to the environment? And the other question is how to prevent it? – user32882 Jan 28 '19 at 10:56
  • @user32882 ever figure this out? – Derek Eden Jan 29 '20 at 23:48
  • not really. Im more of a pycharm user – user32882 Jan 30 '20 at 05:26

0 Answers0