Python import folder never imports - python

I am trying to import this library - https://github.com/abenassi/Google-Search-API
I tried
1. Can not import module search from google module in python
2. Python / ImportError: Import by filename is not supported
3. How to import a module given the full path?
I still can't import
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'google' is not defined
even locally
>>> import imp
>>> google = imp.load_source('google', '/home/arjun/.local/lib/python2.7/site-packages/google/__init__.py')
>>> num_page = 3
>>> search_results = google.search("This is my query", num_page)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'search'
>>> google
<module 'google' from '/home/arjun/.local/lib/python2.7/site-packages/google/__init__.pyc'>

Have you installed it via PIP as described in the README.md on GitHub?
I just tryed to run the search function but the pip install failed for me, the import of google doesn't work neither in python3.
But maybe you can directly use the function search() from modules/standard_search.py by importing this file? I've not installed all dependencies so I was not able to try it myself for now.
Edit: After installing it via PIP in python3.6 this works for me:
from google import google
a = google.search('test')
print(a)
Edit2: The requirements are not set correctly for python3 while pip2 installs selenium and unidecode autmatically, it will fail for pip3 if the modules are not installed. I'm going to post a bug report on GitHub

Related

getting error while importing dbinit in python

hello I am getting error while trying to import dbinit. Is there any specefic library that I should install or download?
import dbinit as d
getting this error -
PS C:\Users\SRLAB-09\Desktop\movie_project> & C:/Users/SRLAB-09/AppData/Local/Programs/Python/Python37-32/python.exe c:/Users/SRLAB-09/Desktop/movie_project/interface.py
Traceback (most recent call last):
File "c:/Users/SRLAB-09/Desktop/movie_project/interface.py", line 1, in <module>
import dbinit as d
ModuleNotFoundError: No module named 'dbinit'
PS C:\Users\SRLAB-09\Desktop\movie_project>
Virtual Environment only:
You need to download the dbinit package in your Virtual Environment.
Otherwise:
Check if you have dbinit downloaded in the first place. If not, download it

Python Import Error : Unable to to import JWTBearerToken from authlib.oauth2.rfc7523

I am trying to use JWTBearerToken from authlib.oauth2.rfc7523. However, I have encountered import error when trying to import JWTBearerToken:
Create a virtual environment and install authlib
$ pyenv virtualenv authlib
$ pyenv activate authlib
$ python -m pip install --upgrade pip
$ pip install authlib
Start authlib and try to import JWTBearerToken
>>> from authlib.oauth2.rfc7523 import JWTBearerToken
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'JWTBearerToken' from 'authlib.oauth2.rfc7523' (/Users/simon/.pyenv/versions/authlib/lib/python3.8/site-packages/authlib/oauth2/rfc7523/__init__.py)
>>>
Try and import via validator module
>>> from authlib.oauth2.rfc7523.validator import JWTBearerToken
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'authlib.oauth2.rfc7523.validator'
The source for the module is here.
What is the correct way to import JWTBearerToken or is this a bug with authlib library?

Why can't I install pyler module?

I get an error while I try to import the pyler module in python. I have uninstalled and then installed the module many times, and also with the .whl file, but still only the info file is generated.
import pyler
When I write this, I get
Traceback (most recent call last): File "c:\Users\USER\Documents\Tanav\VsCode\tut1\Python proj\smth.py", line 1, in <module> import pyler ModuleNotFoundError: No module named 'pyler'
I use python version 3.8.5 on windows 10 64-bit machine.
Please help

Error: How to import method from one file to other in a same directory

I'm using python version 3.6.1
I want to use method of one python file to another located in a same directory. I have used from utils import wit_response in app.py file. And when I compile it this shows an error:
Traceback (most recent call last):
File "app.py", line 4, in
from utils import wit_response
File "E:\Study\Python\fbmessengerbot\utils.py", line 1, in
from wit import Wit
ModuleNotFoundError: No module named 'wit'
In utils.py file I'm using from wit import Wit. The wit package i have already installed.
How can i resolve this.
Thanks in advance.
If you are using a Virtual environment do pip freeze and check whether "wit" package is installed or not.
If "wit" is installed open ipython and check whether you can import the "wit" package.
If "wit" is not imported in ipython check if any dependency packages are need for "wit".

Python AttributeError: 'module' object has no attribute 'Goslate'

I am trying Goslate: Free Google Translate API. I installed goslate using sudo pip install goslate
I wrote a simple program and executed it using python getbn.py command in my terminal.
Here is the code inside getbn.py:
import goslate
gs = goslate.Goslate()
print(gs.translate('hello world', 'bn'))
After executing the command python getbn.py I got the following errors:
Traceback (most recent call last):
File "getbn.py", line 1, in <module>
import goslate
File "/home/ubuntu/Desktop/goslate.py", line 2, in <module>
# -*- coding: utf-8 -*-
AttributeError: 'module' object has no attribute 'Goslate'
Then I tried to run the program by executing python3 getbn.pycommand, and I found the following errors:
Traceback (most recent call last):
File "getbn.py", line 1, in <module>
import goslate
ImportError: bad magic number in 'goslate': b'\x03\xf3\r\n'
How do I fix it? And why are there two different types of erros?
You have a file called goslate.py in your Desktop folder
File "/home/ubuntu/Desktop/goslate.py", line 2, in <module>
^^^^^^^^^^^^^^^^^^^^
This is not the module you installed using pip and it's getting in the way of the import.
You May have simple installed goslate, but you may be using different virtual env. Try to switch to that virtual env, and then run again.

Categories