2017-08-15 77 views
0

當我導入一個python終端沒有問題:導入工程,但不是IPython的

$ python 
Python 3.5.4 | packaged by conda-forge | (default, Aug 10 2017, 01:41:15) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import georasters 
>>> from osgeo import gdal 

ModuleNotFoundError當我做同樣的事情在一個IPython的終端:

$ ipython 
Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09) 
Type "copyright", "credits" or "license" for more information. 

IPython 5.3.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 georasters 
--------------------------------------------------------------------------- 
ModuleNotFoundError      Traceback (most recent call last) 
<ipython-input-1-5a74495660ba> in <module>() 
----> 1 import georasters 

ModuleNotFoundError: No module named 'georasters' 

In [2]: from osgeo import gdal 
--------------------------------------------------------------------------- 
ModuleNotFoundError      Traceback (most recent call last) 
<ipython-input-2-a04b80bf4e65> in <module>() 
----> 1 from osgeo import gdal 

ModuleNotFoundError: No module named 'osgeo' 

爲什麼和怎麼可能我解決這個問題?我有一個MAC El Capitan和python 3.6.1。我已經安裝了所有與conda install ...謝謝。

輸出的

conda list

$ conda list 
# packages in environment at /Users/<myname>/anaconda/envs/cv: 
# 
affine     2.1.0     py35_0 conda-forge 
attrs      17.2.0     py35_0 conda-forge 
boost      1.64.0     py35_3 conda-forge 
boost-cpp     1.64.0      1 conda-forge 
boto3      1.4.4     py35_0 conda-forge 
botocore     1.5.92     py35_0 conda-forge 
bzip2      1.0.6       1 conda-forge 
ca-certificates   2017.7.27.1     0 conda-forge 
cairo      1.14.6      4 conda-forge 
cartopy     0.15.1    np112py35_2 conda-forge 
certifi     2017.7.27.1    py35_0 conda-forge 
chardet     3.0.2     py35_1 conda-forge 
click      6.7      py35_0 conda-forge 
click-plugins    1.0.3     py35_0 conda-forge 
cligj      0.4.0     py35_0 conda-forge 
cloudpickle    0.3.1     py35_0 conda-forge 
curl      7.54.1      0 conda-forge 
cycler     0.10.0     py35_0 conda-forge 
dask      0.13.0     py35_0 ozak 
decorator     4.1.2     py35_0 conda-forge 
descartes     1.1.0     py35_0 conda-forge 
docopt     0.6.2     py35_0 conda-forge 
docutils     0.13.1     py35_0 conda-forge 
expat      2.1.0       3 conda-forge 
fiona      1.7.8     py35_1 conda-forge 
fontconfig    2.12.1      4 conda-forge 
freetype     2.7       1 conda-forge 
freexl     1.0.2       2 conda-forge 
gdal      2.2.0    np112py35_2 conda-forge 
geopandas     0.2.1     py35_4 conda-forge 
geopy      1.11.0     py35_0 conda-forge 
georasters    0.5.6     py35_0 ozak 
geos      3.5.1       1 conda-forge 
gettext     0.19.8.1      0 conda-forge 
giflib     5.1.4       0 conda-forge 
glib      2.51.4      0 conda-forge 
hdf4      4.2.12      0 conda-forge 
hdf5      1.8.18      1 conda-forge 
hypothesis    3.17.0     py35_0 conda-forge 
icu      58.1       1 conda-forge 
idna      2.5      py35_0 conda-forge 
imageio     2.2.0     py35_0 conda-forge 
jmespath     0.9.3     py35_0 conda-forge 
jpeg      9b       0 conda-forge 
json-c     0.12.1      0 conda-forge 
kealib     1.4.7       2 conda-forge 
krb5      1.14.2      0 conda-forge 
libdap4     3.18.3      2 conda-forge 
libffi     3.2.1       3 conda-forge 
libgdal     2.1.4       2 conda-forge 
libgfortran    3.0.0       0 conda-forge 
libiconv     1.14       4 conda-forge 
libkml     1.3.0       1 conda-forge 
libnetcdf     4.4.1.1      6 conda-forge 
libpng     1.6.28      1 conda-forge 
libpq      9.6.3       0 conda-forge 
libspatialindex   1.8.5       1 conda-forge 
libspatialite    4.3.0a      15 conda-forge 
libssh2     1.8.0       1 conda-forge 
libtiff     4.0.6       7 conda-forge 
libxml2     2.9.4       4 conda-forge 
libxslt     1.1.29      5 conda-forge 
lxml      3.8.0     py35_0 conda-forge 
matplotlib    2.0.2     py35_2 conda-forge 
mkl      2017.0.3      0 
munch      2.2.0     py35_0 conda-forge 
ncurses     5.9       10 conda-forge 
networkx     1.11      py35_0 conda-forge 
numpy      1.12.1     py35_0 
olefile     0.44      py35_0 conda-forge 
openjpeg     2.1.2       2 conda-forge 
openssl     1.0.2l      0 conda-forge 
owslib     0.14.0     py35_0 conda-forge 
pandas     0.20.3     py35_1 conda-forge 
pcre      8.39       0 conda-forge 
pillow     4.2.1     py35_1 conda-forge 
pip      9.0.1     py35_0 conda-forge 
pixman     0.34.0      0 conda-forge 
poppler     0.52.0      2 conda-forge 
poppler-data    0.4.7       0 conda-forge 
proj4      4.9.3       4 conda-forge 
psycopg2     2.7.3     py35_0 conda-forge 
pyepsg     0.3.2     py35_0 conda-forge 
pympler     0.5      py35_0 conda-forge 
pyparsing     2.2.0     py35_0 conda-forge 
pyproj     1.9.5.1     py35_0 conda-forge 
pysal      1.13.0     py35_0 conda-forge 
pyshp      1.2.11     py35_0 conda-forge 
python     3.5.4       0 conda-forge 
python-dateutil   2.6.1     py35_0 conda-forge 
pytz      2017.2     py35_0 conda-forge 
pywavelets    0.5.2    np112py35_0 conda-forge 
rasterio     0.36.0     py35_0 conda-forge 
rasterstats    0.11.0     py35_0 ozak 
readline     6.2       0 conda-forge 
requests     2.18.3     py35_0 conda-forge 
rtree      0.8.3     py35_0 conda-forge 
s3transfer    0.1.10     py35_1 conda-forge 
scikit-image    0.13.0     py35_1 conda-forge 
scipy      0.19.1    np112py35_0 
setuptools    36.2.2     py35_0 conda-forge 
shapely     1.5.17     py35_4 conda-forge 
simplejson    3.11.1     py35_0 conda-forge 
six      1.10.0     py35_1 conda-forge 
snuggs     1.4.1     py35_0 conda-forge 
sqlalchemy    1.1.11     py35_0 conda-forge 
sqlite     3.13.0      1 conda-forge 
tk      8.5.19      2 conda-forge 
toolz      0.8.2     py35_0 conda-forge 
tornado     4.5.1     py35_0 conda-forge 
urllib3     1.21.1     py35_0 conda-forge 
wheel      0.29.0     py35_0 conda-forge 
xerces-c     3.1.4       3 conda-forge 
xz      5.2.2       0 conda-forge 
zlib      1.2.8       3 conda-forge 
zope      1.0      py35_0 
zope.interface   4.4.2     py35_0 
+1

似乎你有兩個不同的python安裝,你正在尋找的模塊只適用於一個。 – pvg

+0

太好了,謝謝!我現在應該怎麼做? – user2725109

+1

看看你的$ PATH,運行'which python'和'which ipython'等。也許你有不同的conda安裝程序? – pvg

回答

1

它看起來像你正在運行的Python的不同版本(殼3.5.4和3.6.1的IPython)。

您可以使用conda list列出安裝在活動環境中的軟件包和版本。我的懷疑是你正在運行來自不同環境的ipython。看看它是否安裝在活動環境中。如果您沒有在列表中看到它,請使用conda install -n {env_name} ipython進行安裝。

更新:安裝ipythonconda後,我總是需要再次source activate {env_name}。安裝其他軟件包似乎不需要重新採購。

+0

我試過'$ conda install -n ipython'但它沒有解決問題。 – user2725109

+0

...然後我做了'source deactivate',然後是'source activate ',它工作。謝謝! – user2725109

+0

是的,我剛剛建議!出於某種原因,當您在conda環境中安裝'ipython'時,您確實需要重新來源。接得好! – tdube

相關問題