I was installing jira-python like written in the docs
$ pip install jira-python
but after installation I try to run the example:
from jira.client import JIRA
options = {
'server': 'https://jira.atlassian.com'
}
jira = JIRA(options)
projects = jira.projects()
keys = sorted([project.key for project in projects])[2:5]
issue = jira.issue('JRA-1330')
import re
atl_comments = [comment for comment in issue.fields.comment.comments
if re.search(r'#atlassian.com$', comment.author.emailAddress)]
jira.add_comment(issue, 'Comment text')
issue.update(summary="I'm different!", description='Changed the summary to be different.')
issue.delete()
getting the following error:
**Traceback (most recent call last):
File "jira.py", line 4, in <module>
from jira.client import JIRA
File "/home/ubuntu/jira.py", line 4, in <module>
from jira.client import JIRA
ImportError: No module named client**
Any idea about the problem here? I tried it also on an Amazon instance, but same problem...
seems like the reason was that my test file was named jira.py :) thanks for your help Inbar!
Related
Previos title was:
AttributeError: module 'json' has no attribute 'loads'
I changed it because it looks similar to this but at the link that i provided, the problem seems that the person was having a file called json.py that was tricking the import to think that is importing a local file and not the json from standard library. My problem is that I don't have any local file called json.py;
I am wondering if it has to do anything related to PATH or the structure of my project. Any suggestion might help.
error traceback:
File "D:\Me\IdeaProjects\src\app\repositories\user_repository.py", line 14, in get_user
user = json.loads(file.read())
I am running the code in Windows 10, and intelliJ ide.
Python version: 3.7.4
Tried the code from the official documentation this:
import json
def as_complex(dct):
if '__complex__' in dct:
return complex(dct['real'], dct['imag'])
return dct
json.loads('{"__complex__": true, "real": 1, "imag": 2}', object_hook=as_complex)
And got this error as well:
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
json.loads('{"__complex__": true, "real": 1, "imag": 2}',object_hook=as_complex)
AttributeError: module 'json' has no attribute 'loads'
When I try to import loads explicitly i get this error:
ImportError: cannot import name 'loads' from 'json' (unknown location)
I had python installed in Admin account in window 10 and it was installed with Admin privileges, but when i used in another account I could not use the packages, however installing the python in the current account did fix the problem.
Try to import loads explicitly:
import json
from json import loads
I was trying to use Targetting search API from facebook business SDK API.
ImportError: No module named facebookads.adobjects.targetingsearch
Using Python 2.7.12
~
Was trying to execute this piece of code:
from facebookads.adobjects.targetingsearch import TargetingSearch
params = {
'q': 'un',
'type': 'adgeolocation',
'location_types': ['country'],
}
resp = TargetingSearch.search(params=params)
print(resp)
Actual result :
Traceback (most recent call last):
File "test.py", line 2, in <module>
from facebookads.adobjects.targetingsearch import TargetingSearch
ImportError: No module named facebookads.adobjects.targetingsearch
Facebook Marketing API docs a bit outdated. You should replace the import from:
from facebookads.adobjects.targetingsearch import TargetingSearch
to:
from facebook_business.adobjects.targetingsearch import TargetingSearch
Also, before requesting targeting data, you should initialize FacebookAdsApi with your generated access token:
from facebook_business.api import FacebookAdsApi
FacebookAdsApi.init(access_token=access_token)
I can't run my script I'm using python3 and I install pyrebase and his dependencies
I got this below exception when I try to run my script on linux ubuntu
Traceback (most recent call last):
File "scrapping2fb.py", line 9, in <module>
import pyrebase
File "/usr/local/lib/python3.4/dist-packages/pyrebase/__init__.py", line 1, in <module>
from .pyrebase import initialize_app
File "/usr/local/lib/python3.4/dist-packages/pyrebase/pyrebase.py", line 19, in <module>
from requests.packages.urllib3.contrib.appengine import is_appengine_sandbox
Can some one help me
Thank you
The script that i try to run
from urllib.request import urlopen ,URLError,HTTPError,Request
from socket import timeout
from bs4 import BeautifulSoup
from time import sleep
import mysql.connector
from datetime import datetime
import pyrebase
def is_exist_firebase_db_AR(siteName,title):#(siteName,title):
global config
global email
global password
firebase = pyrebase.initialize_app(config)
db=firebase.database()
auth = firebase.auth()
user = auth.sign_in_with_email_and_password(email, password)
all_items = db.child("items_ar").get(user['idToken'])
if(all_items.each() is not None):
for item in all_items.each():
if(siteName in item.val().get("nomSite") and title in item.val().get("titre")):
return 1
return 0
This is a problem with the pyrebase package.
Since commit 8e17600ef60de4faf632acb55d15cb3c178de9bb which went into v2.16.0, requests no longer bundle urllib3.
The package pyrebase is relying on this implementation detail, and, like all things that rely on implementation details eventually do, was broken.
I'm getting this error when trying to import a module from the Prov package.
Here is the contents of my file:
#!/usr/bin/env
import sys
egg_path='/Library/Python/2.7/site-packages/prov-1.5.0-py2.7.egg/prov'
sys.path.append(egg_path)
#... rest of code
import model as prov
def main():
# Create a new provenance document
d1 = ProvDocument() # d1 is now an empty provenance document
# Declaring namespaces for various prefixes used in the example
d1.add_namespace('now', 'http://www.provbook.org/nownews/')
d1.add_namespace('nowpeople', 'http://www.provbook.org/nownews/people/')
d1.add_namespace('bk', 'http://www.provbook.org/ns/#')
# Entity: now:employment-article-v1.html
e1 = d1.entity('now:employment-article-v1.html')
# Agent: nowpeople:Bob
d1.agent('nowpeople:Bob')
And here is the output:
Traceback (most recent call last):
File "prov.py", line 6, in <module>
import model as prov
File "/Library/Python/2.7/site-packages/prov-1.5.0-py2.7.egg/prov/model.py", line 25, in <module>
from prov import Error, serializers
ImportError: cannot import name Error
Any ideas or fixes? I installed Prov using easy_install prov.
You need to rename your module file prov.py. It prevents import of the third-party library because the module name conflicts.
Make sure prov.pyc is removed.
I found the error. The name of my file that I was trying to import into was also called prov.py . It was a circular dependency issue.
Thank you guys for such quick responses!
I am importing boto.dynamodb.table and getting a syntax error. I don't see how it is related to what I'm doing. I haven't implemented / used it and yet upon launching it finds a syntax error.
The error from my console looks like this:
File "api.py", line 10, in <module>
import dynamoAccess
File "/Users/tai/Documents/workspace/testSelenium/testS/dynamoAccess.py", line 6, in <module>
from boto.dynamodb2.table import Table
File "/Library/Python/2.7/site-packages/boto/dynamodb2/table.py", line 3, in <module>
from boto.dynamodb2.fields import (HashKey, RangeKey,
File "/Library/Python/2.7/site-packages/boto/dynamodb2/fields.py", line 1, in <module>
from boto.dynamodb2.types import STRING
File "/Library/Python/2.7/site-packages/boto/dynamodb2/types.py", line 4, in <module>
from boto.dynamodb.types import Dynamizer
File "/Library/Python/2.7/site-packages/boto/dynamodb/types.py", line 112
]
^
SyntaxError: invalid syntax
The code that I believe this is related to is the first few lines (aka the dynamo table import) of dynamoAccess:
This is what I have:
import cleaner
import datetime
import awsAccess
import boto
from boto import dynamodb2
from boto.dynamodb2.table import Table
#create a connection to amazon s3
#aws_access_key_id=getenv('AWS_ACCESS_KEY');
#aws_secret_access_key=getenv('AWS_SECRET_KEY');
#aws_dynamo_region=getenv('DYANAMO_REGION')
#for running in pydev
aws_access_key_id=awsAccess.aws_access_key_id
aws_secret_access_key=awsAccess.aws_secret_access_key
aws_dynamo_region=awsAccess.aws_dynamo_region
decompiled_dynamo_table="decompiled_swfs"
text_dynamo_table="decompiled_swf_text"
image_dynamo_table="images_decompiled"
_dynamo_table="decompiled_swf_text"
Has anyone encountered this? I haven't modified the boto file.
Edit:
resinstalled boto but still getting the error:
Name: boto
Version: 2.31.1
Edit 2: Solved see answer below. Boto had a bug
Fixed - I replaced the boto dynamodb/types.py file with the one in github: https://github.com/boto/boto
There was a ] out of place that needed to be fixed. This was already fixed in the github version but apparently not yet pushed to pip
I believe that this may occur for other people due to the above error. If you encounter this simply update your file from github (or edit it yourself)