Import only works in interpreter - python

import twitter
api = twitter.Api(consumer_key='consumer_key',
consumer_secret= 'consumer_secret',
access_token_key='access_token_key',
access_token_secret='access_token_secret')
Above code works fine in the interpreter and I am able to get the information that I am looking for. However, python importScript.py with the exact contents above gives error:
AttributeError: 'module' object has no attribute 'Api'
I am not sure what the issue is and have searched for related issues with no resolution. My python interpreter and command are the same version.

Related

sift.SiftPlan giving AttributeError: 'NoneType' object has no attribute 'create_context'

I am using Ubuntu environment and python 3.6. When i run "sift_ocl = sift.SiftPlan(template=image, devicetype="GPU")" then I am facing below error:
"AttributeError: 'NoneType' object has no attribute 'create_context'".
Few platforms also mentioned to check "import pyopencl" and it is also giving error on import "ImportError: libsvml.so: cannot open shared object file: No such file or directory", for which I didn't find exact solution.
I tried similar problems solution which are posted online and having ****.so dynamically linked shared object libraries issues but didn't work for me.
Please guide me, thanks.

module 'serial' has no attribute 'Serial' (gnuradio)

I created a "python block" using gnuradio on WINDOWs, got
module serial' has no attribute Serial
error in it, but put
'SerialIn = serial.Serial("COM16",0)'
After commenting it out, there is no error, which proves that it is not a problem of
import serial
There is a method to reinstall it on the Internet, but it still doesn't work, how can I fix it?

Issues with Google Earth Engine Python API - "AttributeError: 'module' object has no attribute 'inet_pton'"

I'm trying to use Google Earth Engine via the Python API. I used pip to install (pip install earthengine-api) and when I run pip list earthengine-api shows up.
However, I'm trying to go through the Python Installation Guide and when I tried to run the Initialization sequence:
import ee
ee.Authenticate()
ee.Initialize()
It works up to a point. I am able to get and enter the verification code, but running the cell fails with the error:
AttributeError: 'module' object has no attribute 'inet_pton'
Does anyone have any idea what is causing this error and how to fix it?

Python interpreter can't find face module although it is in the build directory of Opencv 3.0.0

I was reading this tutorial and when I tried to run the attached face recognizer python code
it gave me the following error :
AttributeError: 'module' object has no attribute 'face'
I am on ubuntu 15.04, I have python 2.7, numpy, matplotlib and PIL installed and updated.
I pulled the latest sources of opencv from http://github.com/itseez/openc..., compiled according to the documentation.I added the latest source of opencv contrib from https://github.com/Itseez/open..., compiled according to the documentation.
To make sure:
I have the python bindings i typed the following in the python shell:
import cv2
cv2.version
it returned the following '3.0.0'
The face module folder already in the modules folder in the build directory
I modified the original code with my recent images database directory and haarcascade xml file and
recognizer = cv2.createLBPHFaceRecognizer()
to be
recognizer = cv2.face.createLBPHFaceRecognizer()
When i tried to run type
import cv2
help(cv2.face)
it returned the following error AttributeError: 'module' object has no attribute 'face'
When I tried to explore this file: build/modules/python2/pyopencv_generated_types.h I found that:
pyopencv_face_BasicFaceRecognizer_Type.tp_base = &pyopencv_face_FaceRecognizer_Type; pyopencv_face_LBPHFaceRecognizer_Type.tp_base = &pyopencv_face_FaceRecognizer_Type;
I googled extensively to find a solution and I tried all the available solutions but still stuck at the same point. AttributeError: 'module' object has no attribute 'face'
The last activity about the similar questions was from 7 month ago so I re-ask this question to figure out if there are new answers about this issue.
What should I do?

Python Matlab Engine Error

I am using the Matlab Engine for Python.
When I try to run the command:
matlab.engine.find_matlab()
in the python prompt, I get the following error:
AttributeError: 'module' object has no attribute 'find_matlab'
I looked into the source code of the corresponding module (matlabeninge.py), there is no 'find_matlab' method in it, or other methods listed in the Mathworks documentation.
Though I can properly start a Matlab session using:
matlab.engine.matlab_startup()
I tried reinstalling both Matlab & the Python package, nothing changed. It's as if the module lacks some code.
Has anyone else encountered this?
Please try to follow the example listed here
The syntax is :
names = matlab.engine.find_matlab()
did that solve the issue ?
I used the following line to solve a similar issue: (so I imported matlab.engine two times)
import matlab.engine
I called eng = matlab.engine.start_matlab('-desktop') after it and got the following error message without the import:
AttributeError: 'int' object has no attribute 'engine'

Categories

Resources