How to fix: AttributeError: module 'twint' has no attribute 'config' - python-3.x

I have installed twint with:
pip3 install twint
which resulted in a successful installation:
Successfully installed twint-2.1.8
It works to get tweets from twitter using Command Prompt(CLI) commands but when I try to run the example in Spyder IDE it gives me the error:
"Traceback (most recent call last):
File "<ipython-input-13-7b77905cef0c>", line 1, in <module>
runfile('C:/Users/myname/twint.py', wdir='C:/Users/myname')
File "C:\Users\myname\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\myname\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/myname/twint.py", line 8, in <module>
import twint
File "C:\Users\myname\twint.py", line 9, in <module>
c = twint.Config()
AttributeError: module 'twint' has no attribute 'Config'
Here is my code:
import twint
c = twint.Config()
c.Username = "twitterAccountName"
twint.run.Search(c)
However, I looked twint related issues on GitHub found here but the solution provided here not worked for me. Does anyone know where the error coming from? How do I fix it?

The issue you linked to is the exact same problem you have. You need to rename your file to not be twint.py
Rename this file runfile('C:/Users/myname/twint.py
If you get other errors, then that's a separate issue

Related

Why pyexiv2 raises an error during runtime execution

I'm trying to use pyexiv2 to geotag photos from historical location data. However, my installation of pyexiv2 seems to be broken.
I'm running this script on a MacBook with MacOS Monterey. This was working perfectly on my previous MacBook so I believe it has something to do with the installation.
Here is the runtime error, it doesn't even pass import pyexiv2 at line 1 of the code.
stu#192 Development % python3 GPS-image.py /Users/stu/02.\ 2017-03-02\ 11.08.09.jpg -34.45223 132.342535
Traceback (most recent call last):
File "/Users/stu/Development/GPS-image.py", line 1, in <module>
import pyexiv2
File "/opt/homebrew/lib/python3.9/site-packages/pyexiv2/__init__.py", line 6, in <module>
from .core import *
File "/opt/homebrew/lib/python3.9/site-packages/pyexiv2/core.py", line 1, in <module>
from .lib import exiv2api
File "/opt/homebrew/lib/python3.9/site-packages/pyexiv2/lib/__init__.py", line 25, in <module>
ctypes.CDLL(os.path.join(lib_dir, 'libexiv2.dylib'))
File "/opt/homebrew/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/opt/homebrew/lib/python3.9/site-packages/pyexiv2/lib/libexiv2.dylib, 0x0006): tried: '/opt/homebrew/lib/python3.9/site-packages/pyexiv2/lib/libexiv2.dylib' (no such file), '/usr/local/lib/libexiv2.dylib' (no such file), '/usr/lib/libexiv2.dylib' (no such file)
Clearly files are missing, but why and how do I get them correctly installed?
Can someone tell me what the problem is and how to fix it?
Many thanks,
Stu

Q: How to fix the missing dependancies in pyzbar

I am currently using spyder via anaconda with python 3.8.5 on windows 10 and I am trying to use the pyzbar package to make a barcode reader. When I try to run the script I get this error message when trying to run from pyzbar.pyzbar import decode and from pyzbar import pyzbar:
Traceback (most recent call last):
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 58, in load
dependencies, libzbar = load_objects(Path(''))
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp>
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 459, in LoadLibrary
return self._dlltype(name)
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<ipython-input-1-95ae0761f4b5>", line 1, in <module>
from pyzbar.pyzbar import decode
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\pyzbar.py", line 7, in <module>
from .wrapper import (
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 139, in <module>
zbar_version = zbar_function(
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 136, in zbar_function
return prototype((fname, load_libzbar()))
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 115, in load_libzbar
libzbar, dependencies = zbar_library.load()
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 60, in load
dependencies, libzbar = load_objects(Path(__file__).parent)
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp>
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 459, in LoadLibrary
return self._dlltype(name)
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
When trying to run just import pyzbar it will compile, but it will not be able to access any of the function. When I try I get this message:
Traceback (most recent call last):
File "<ipython-input-3-26272af93b8a>", line 1, in <module>
pyzbar.pyzbar.decode()
AttributeError: module 'pyzbar' has no attribute 'pyzbar'
I have looked up the documentation for pyzbar on github which states "The zbar DLLs are included with the Windows Python wheels", but have not found this anywhere. The closest to "Windows Python wheels" I have found is the wheel package which does not contain any information about pyzbar.
Any advice on how to fix this?
Visit https://pypi.org/project/pyzbar/#files to download pyzbar-0.1.8-py2.py3-none-win_amd64.whl.
You can find all the DLL files inside the wheel package.
I have just encountered this problem.
If your OS & python are x64 version, it's just because of lack of vc 2013 x64 runtime.
You can find Visual C++ Redistributable Packages for Visual Studio 2013 here
download & install.
I was facing similar issue just installed Visual
C++ 64 bit version on my computer and restarted. Choose between vcredist_x86.exe or vcredist_x64.exe based on your machine.
https://www.microsoft.com/en-us/download/confirmation.aspx?id=40784. Hope this solves your issue as well.

ImportError: cannot import name 'Bitrix24' from 'bitrix24'

I installed this module https://github.com/gebvlad/bitrix24-python-sdk using pip
python3.8 -m pip install -I bitrix24-python-sdk
When I try to import this module
from bitrix24 import Bitrix24
I am getting the next error
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/vinni/Documents/GitHub/funnel.py", line 2, in <module>
from bitrix24 import Bitrix24
ImportError: cannot import name 'Bitrix24' from 'bitrix24' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bitrix24/__init__.py)
OS - MacOS 10.15
Python - 3.8
I ran into the same issue, I solved it by using
from bitrix24.bitrix24 import Bitrix24
To put it simply, I looked at the modules-directory of Python.
from bitrix24 is navigating to the directory,
.bitrix24 is referring to the bitrix24.py file inside this directory, and import Bitrix24 calls the class inside this file.
Hope this also helps you find module errors in the future!

Which packages are installed?

I'm new to Python.
I'm using winpython3 and winspyder3. How can I check which packages, modules and plugins are installed?
I didn't find anything here.
Thanks for the answers... but....
#Vineeth Sai: I'm using winspyder3, I get these error:
Start of code
pip freeze
The following command must be run outside of the IPython shell:
$ pip freeze
The Python package manager (pip) can only be used from outside of IPython.
Please reissue the `pip` command in a separate terminal or command prompt.
See the Python documentation for more information on how to install packages:
https://docs.python.org/3/installing/
End of Code
# Rajeev Atmakuri:
With the Code of your link, I get following output:
Start of code:
runfile('D:/Python/packages_001.py', wdir='D:/Python')
Traceback (most recent call last):
File "<ipython-input-6-a7b650970979>", line 1, in <module>
runfile('D:/Python/packages_001.py', wdir='D:/Python')
File "C:\WPy-3662\python-3.6.6.amd64\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
execfile(filename, namespace)
File "C:\WPy-3662\python-3.6.6.amd64\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/Python/packages_001.py", line 9, in <module>
installed_packages = pip.get_installed_distributions()
AttributeError: module 'pip' has no attribute 'get_installed_distributions'
End of code
at all:
if you know octave: with
start of code:
pkg list
end of code
you get a complete list of the installed packages...

errors with pyautogui on Windows 7

I am wanting to use pyautogui to automate some tasks but i am having trouble getting the package to work on Windows 7.
I am currently using anaconda and spyder (i have also tried python IDLE). I can install the pyautogui package without any errors, but when i try to run a simple command:
import pyautogui
pyautogui.displayMousePosition()
The above i got from a youtube video of Al Sweigart doing a demo of pyautogui, and from the outcome i would expect to see the x, y coordinates of the mouse pointer and the R,G,B numbers.
But when I run it I get the following messages:
runfile('C:/Users/david/.spyder-py3/temp.py', wdir='C:/Users/david/.spyder-py3')
Reloaded modules: pymsgbox, pyautogui, pyautogui._pyautogui_win, pymsgbox._native_win, pymsgbox.native, pyscreeze, pytweening
Press Ctrl-C to quit.
Traceback (most recent call last):
File "<ipython-input-5-0007268e4f6f>", line 1, in <module>
runfile('C:/Users/david/.spyder-py3/temp.py', wdir='C:/Users/david/.spyder-py3')
File "C:\Users\david\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\Users\david\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/david/.spyder-py3/temp.py", line 2, in <module>
pyautogui.displayMousePosition()
File "C:\Users\david\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\pyautogui\__init__.py", line 1027, in displayMousePosition
pixelColor = pyscreeze.screenshot().getpixel((x, y))
File "C:\Users\david\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\pyscreeze\__init__.py", line 309, in _screenshot_win32
im = ImageGrab.grab()
NameError: name 'ImageGrab' is not defined
I have tried manually installing the dependenciies (pillow) in case that was the issue, but I cannot figure out how to fix the problem. I know the above message give a lot of info but I don't understand well enough to fix the issue.
Can anyone help? or tell me where i'm going wrong?

Resources