I am getting below ImportError while running a python file.
ImportError: No module named osgeo.gdal_array
!/usr/bin/env python
from osgeo.gdal_array import BandReadAsArray
However, if i try to import same from command line, it runs fine.
$ which python
/home/hduser/anaconda2/bin/python
$ python
>>> from osgeo.gdal_array import BandReadAsArray
>>>
Also, please see the below where i am getting the same ImportError.
$ /usr/local/bin/python2.7
>>> from osgeo.gdal_array import BandReadAsArray
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named osgeo.gdal_array
I figured out that there is something going on between different versions of python. But, i do not want to change the original source code.
How do i make my program run without changing anything within the code of calling python installed in anaconda explicitly?
Related
I found that when I run my scripts from environment - everything is OK.
But, when I try to run them from bash - I receive different errors with import modules. (ModuleNotFoundError, ImportError)
I didn't set the environment at all, so, please, tell me, what I should configure to succeed with it.
I use python 3.7
Received the next error:
Traceback (most recent call last):
File "main.py", line 1, in <module> from package_3.file3 import *
ModuleNotFoundError: No module named 'package_3'
The structure is:
package_1
file1.py
package_2
file2.py
package_3
file3.py
package_4
file4.py
What happens is, probably, that your working environment is python3, and when you run things in the shell, it's using python2. To solve it, run your script with python3 in the shell, as in:
python3 my_script.py
I have a simple module called mini. It can be imported in either python interactive interpreter or a python .py script. The module is a C extension based so I want to debug it in gdb (version > 7). I learned that gdb has python command to interpret python command or script like:
(gdb) python import mini
However, it failed to import the module by saying:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named mini
I guess it might be the environment setting with either my gdb setting or my linux searching path setting. What will be the possible reason of this problem? Thanks.
I am trying to edit Libreoffice-calc sheets through a python script using the library oosheet. I've followed their documentation and it seems to have installed correctly. But when I run "from oosheet import OOSheet as S" in the python shell, I returns this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/herm/.local/lib/python2.7/site-packages/oosheet/__init__.py", line 30, in <module>
from com.sun.star.awt import WindowDescriptor
ImportError: No module named com.sun.star.awt
On my Ubuntu system (14.04 Trusty, LO 4.2.8.2), LibreOffice uses python 3. So this works in a terminal:
python3
>>> import uno
>>> from com.sun.star.awt import WindowDescriptor
But this fails:
python
>>> import uno
ImportError: No module named uno
The OOSheet web site does not say that it works on python 3, so you may need to switch to AOO, which still uses python 2. Or why not just use PyUNO directly instead of OOSheet.
I downloaded this library: https://github.com/bufferapp/buffer-python
Ran the setup.py install, and then tried to run some code using the newly installed library.
What happens though is I get this error:
Traceback (most recent call last):
File "twitter-quote-bot.py", line 14, in <module>
from buffpy.managers.profiles import Profiles
ImportError: No module named managers.profiles
The only way I've found to fix it is to move my program (twitter-quote-bot) into the downloaded folder from Buffer and run it there.
Did I do something wrong in the installation? It seems like I should be able to do these imports globally.
Thanks in advance!
I've decided to give Python a try on Netbeans. The problem so far is when try to run program I know works, i.e. if I ran it through the terminal. For the project I selected the correct Python version (2.6.5). And received the following error:
Traceback (most recent call last): File
"/Users/XXX/NetBeansProjects/NewPythonProject3/src/newpythonproject3.py",
line 4, in
import sqlite3 ImportError: No module named sqlite3
Search for PYTHONPATH. You probably have different settings in your OS and Netbeans.