Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Confluence Python API

Hello. I’ve tried installing using pip install atlassian-python-api, but when I write the script, python is giving me ModuleNotFoundError: No module named ‘atlassian’ when I run my Script.Please Help. Thanks in Advance.
Reference link: https://atlassian-python-api.readthedocs.io/index.html

This is the code.

from atlassian import Confluence

confluence = Confluence(
url=‘http://localhost:8090’,
username=‘admin’,
password=‘admin’)

status = confluence.create_page(
space=‘DEMO’,
title=‘This is the title’,
body=‘This is the body. You can use HTML tags!’)

print(status)

2 answers

1 vote

You may have to use python3 instead of python2 or python (if python2 is the default on your OS).

I tested it (same script) and I was able to create the page by either calling the script with python3 or setting the shebang in the script's first line pointing it to 

#!/usr/bin/python3

Can you confirm if the script runs when calling it with python3?

Dave Chevell Atlassian Team Jun 19, 2020

atlassian-python-api is compatible with python 2 and python 3. You're not far off though - it's likely because the wrong python installation is being used, rather than the wrong python version.

thanks @Osimar Medeiros it did work while running it with "python3 <script>"

0 votes
Dave Chevell Atlassian Team Jun 19, 2020

The error you're receiving indicates that, wherever you may have installed the package, it's not in the python installation that you're using to run the script.

If you have python 2 and python 3 installed, you may have used the pip from one installation whilst you're running the script with the other. 

The easiest thing to check is to run which pip and which python (or which python3, whichever is the binary that you used when you tried running the script). Are they in the same place? If not, then that explains why: the python you're running is from a different installation than the pip you used to install.

As a general rule I would recommend using virtual environments, as this simplifies everything and ensures you're using a default python local to your project:

mkdir my_project && cd my_project
python3 -m venv .env #this creates a virtual environment in the folder ".env"
source .env/bin/activate
pip3 install atlassian-python-api
python3 myscript.py

If you take this approach you should be guaranteed to be using the right python and pip from the virtual environment installation and you shouldn't get the module import error.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

177 views 0 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you