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)
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.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.