简体   繁体   English

Python模块已安装但无法导入

[英]Python modules are installed but can't be imported

I'm a novice Python user and slowly going crazy over following problem: I installed a number of modules for Python 2.7 (win34) using pip. 我是Python的新手,并且对以下问题逐渐发疯:我使用pip为Python 2.7(win34)安装了许多模块。 I confirmed that the modules are indeed installed. 我确认确实安装了模块。 Then I import the modules in a .py script (using Atom editor): 然后,将模块导入.py脚本中(使用Atom编辑器):

import numpy as np
import pandas as pd
import fiona
import geopandas as gpd
import shapely

There is no problem with importing the first two modules, but fiona, geopandas and shapely trigger errors: 导入前两个模块没有问题,但是fiona,geopandas和形状触发错误:

ImportError: No module named geopandas

I suspect the issue may be related to the different directories where the modules are stored, but not sure how to address this. 我怀疑问题可能与存储模块的不同目录有关,但不确定如何解决。 I saw several similar questions, but no answers..Grateful for any tips! 我看到了几个类似的问题,但没有答案。感谢任何提示!

There are two cases in this situation. 在这种情况下有两种情况。 It might be permission issue or owner issue. 可能是权限问题或所有者问题。

  1. Check permission of installed module. 检查已安装模块的权限。 And provide it all permission. 并提供所有许可。

    chmod -R 777 chmod -R 777

  2. Second thing, it may be owner issue, might be you installed module using 第二件事,可能是所有者问题,可能是您使用

    apt-get install module_name or pip install modual_name apt-get install module_name或pip install modual_name

try to install modual using sudo 尝试使用sudo安装模态

sudo apt-get install module_name or sudo pip install modual_name sudo apt-get install module_name或sudo pip install modual_name

If above thing not worked for you just try with 如果以上问题都不适合您,请尝试

sudo ln -s /usr/bin/python2.7 /usr/bin/python

it will tell system to find the default system python. 它会告诉系统找到默认的系统python。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM