AttributeError: 'Repo' object has no attribute 'create_pull' - python

I'm currently running the following python script. The intention is to be able to automatically create a PR.
if new_repo != None: #if there are files within the repo
current = new_repo.create_head(new_branch)
new_repo.git.checkout(current)
new_repo.git.rm('file.yml') #remove the file
print("deleting file")
new_repo.git.commit("-m",'deleting file') #apply a commit message
print("changes are being commited")
new_repo.git.push('--set-upstream', new_repo.remote().name, new_branch) #set an upstream for the branch to remote
print("changes are being pushed")
new_repo.create_pull(title="deleting file", body="just a line to test", head=new_branch, base="master")
The code is working up until I try to create a PR. I end up with the following error:
AttributeError: 'Repo' object has no attribute 'create_pull'
Currently I am using python3 and it's version is Python 3.8.2. I'm unsure about the version on pygithub. I know I have installed it because when I run pip3 install pygithub I get the following output:
Requirement already satisfied: pygithub in /usr/local/lib/python3.9/site-packages (1.55)
Requirement already satisfied: requests>=2.14.0 in /usr/local/lib/python3.9/site-packages (from pygithub) (2.25.1)
Requirement already satisfied: pynacl>=1.4.0 in /usr/local/lib/python3.9/site-packages (from pygithub) (1.4.0)
Requirement already satisfied: deprecated in /usr/local/lib/python3.9/site-packages (from pygithub) (1.2.12)
Requirement already satisfied: pyjwt>=2.0 in /usr/local/lib/python3.9/site-packages (from pygithub) (2.1.0)
Requirement already satisfied: cffi>=1.4.1 in /usr/local/lib/python3.9/site-packages (from pynacl>=1.4.0->pygithub) (1.14.4)
Requirement already satisfied: six in /usr/local/lib/python3.9/site-packages (from pynacl>=1.4.0->pygithub) (1.15.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.9/site-packages (from cffi>=1.4.1->pynacl>=1.4.0->pygithub) (2.20)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (2021.5.30)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (1.26.6)
Requirement already satisfied: chardet<5,>=3.0.2 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (2.10)
Requirement already satisfied: wrapt<2,>=1.10 in ./Library/Python/3.9/lib/python/site-packages (from deprecated->pygithub) (1.12.1)
Is there something that I am missing with my troubleshooting? Is the code incorrect? As far as I know, I've been looking at the following SO postand this PyGithub post.
Could someone help me out? If someone could provide an explanation as well that'll be amazing.
Thanks!

Related

Can't run quantised models on machine

I'm trying to get the 8bit quantised bloom models running on my machine.
I (seem to have) installed all of the dependencies, however, when I run my script, it errors - saying it can't find the cudaGetRuntime
I then tried switching to to conda environemnt - using conda activate (and conda install cudatoolkit)
and it says it cant find "bitsandbytes"
root#localhost:~# pip install bitsandbytes accelerate transformers
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Requirement already satisfied: bitsandbytes in /usr/local/lib/python3.10/dist-packages (0.35.4)
Requirement already satisfied: accelerate in /usr/local/lib/python3.10/dist-packages (0.15.0)
Requirement already satisfied: transformers in /usr/local/lib/python3.10/dist-packages (4.25.1)
Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from accelerate) (21.3)
Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from accelerate) (5.9.4)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from accelerate) (5.4.1)
Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from accelerate) (1.23.4)
Requirement already satisfied: torch>=1.4.0 in /usr/local/lib/python3.10/dist-packages (from accelerate) (1.13.0)
Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.10/dist-packages (from transformers) (4.64.1)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from transformers) (2.27.1)
Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers) (3.8.2)
Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.13.2)
Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (2022.10.31)
Requirement already satisfied: huggingface-hub<1.0,>=0.10.0 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.11.1)
Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.10.0->transformers) (4.4.0)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/lib/python3/dist-packages (from packaging>=20.0->accelerate) (3.0.7)
Requirement already satisfied: nvidia-cuda-nvrtc-cu11==11.7.99 in /usr/local/lib/python3.10/dist-packages (from torch>=1.4.0->accelerate) (11.7.99)
Requirement already satisfied: nvidia-cublas-cu11==11.10.3.66 in /usr/local/lib/python3.10/dist-packages (from torch>=1.4.0->accelerate) (11.10.3.66)
Requirement already satisfied: nvidia-cuda-runtime-cu11==11.7.99 in /usr/local/lib/python3.10/dist-packages (from torch>=1.4.0->accelerate) (11.7.99)
Requirement already satisfied: nvidia-cudnn-cu11==8.5.0.96 in /usr/local/lib/python3.10/dist-packages (from torch>=1.4.0->accelerate) (8.5.0.96)
Requirement already satisfied: wheel in /usr/local/lib/python3.10/dist-packages (from nvidia-cublas-cu11==11.10.3.66->torch>=1.4.0->accelerate) (0.38.4)
Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from nvidia-cublas-cu11==11.10.3.66->torch>=1.4.0->accelerate) (65.5.1)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root#localhost:~# python /tmp/pycharm_project_354/bloom8.py
File "/tmp/pycharm_project_354/bloom8.py", line 6, in <module>
from bitsandbytes.functional import quantize_blockwise, dequantize_blockwise
ModuleNotFoundError: No module named 'bitsandbytes'

plaidml-setup is not recognized on Windows, even after successful installation

I followed all the steps as on the documentation from VertexAI but after installing plaidml-keras, when I try to run setup, it throws an error.
C:\Users\anura>pip install plaidml-keras
Requirement already satisfied: plaidml-keras in c:\python39\lib\site-packages (0.7.0)
Requirement already satisfied: six in c:\python39\lib\site-packages (from plaidml-keras) (1.15.0)
Requirement already satisfied: keras==2.2.4 in c:\python39\lib\site-packages (from plaidml-keras) (2.2.4)
Requirement already satisfied: plaidml in c:\python39\lib\site-packages (from plaidml-keras) (0.7.0)
Requirement already satisfied: keras-preprocessing>=1.0.5 in c:\python39\lib\site-packages (from keras==2.2.4->plaidml-keras) (1.1.2)
Requirement already satisfied: scipy>=0.14 in c:\python39\lib\site-packages (from keras==2.2.4->plaidml-keras) (1.6.2)
Requirement already satisfied: numpy>=1.9.1 in c:\python39\lib\site-packages (from keras==2.2.4->plaidml-keras) (1.20.2)
Requirement already satisfied: keras-applications>=1.0.6 in c:\python39\lib\site-packages (from keras==2.2.4->plaidml-keras) (1.0.8)
Requirement already satisfied: pyyaml in c:\python39\lib\site-packages (from keras==2.2.4->plaidml-keras) (5.4.1)
Requirement already satisfied: h5py in c:\python39\lib\site-packages (from keras==2.2.4->plaidml-keras) (3.2.1)
Requirement already satisfied: cffi in c:\python39\lib\site-packages (from plaidml->plaidml-keras) (1.14.5)
Requirement already satisfied: enum34>=1.1.6 in c:\python39\lib\site-packages (from plaidml->plaidml-keras) (1.1.10)
Requirement already satisfied: pycparser in c:\python39\lib\site-packages (from cffi->plaidml->plaidml-keras) (2.20)
C:\Users\anura>plaidml-setup
'plaidml-setup' is not recognized as an internal or external command,
operable program or batch file.
Please can someone help me get through this.
So, I didn't find a solution to the original problem, even after multiple reinstalls. Finally, I uninstalled Python, and installed Anaconda3. Installing plaidml through the Anaconda prompt worked. Sadly my GPU is too old to even be recognized. AMD Radeon HD 7870.
But hey, if any future reader of this post has the same issue, try Anaconda prompt. Its highly probable you have it installed anyways. Happy Coding.

ModuleNotFoundError: No module named 'Crypto' even after installing it

I am trying to run a Jupyter notebook cell that uses firebase module on MacOS Big Sur Python 3.8.2 but it keeps returning this error:
ModuleNotFoundError: No module named 'Crypto'
I ran a pip install Crypto but it said requirement already satisfied
Requirement already satisfied: Crypto in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.4.1)
Requirement already satisfied: Naked in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from Crypto) (0.1.31)
Requirement already satisfied: shellescape in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from Crypto) (3.8.1)
Requirement already satisfied: pyyaml in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from Naked->Crypto) (5.4.1)
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from Naked->Crypto) (2.25.1)
Requirement already satisfied: idna<3,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests->Naked->Crypto) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests->Naked->Crypto) (2020.12.5)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests->Naked->Crypto) (1.26.3)
Requirement already satisfied: chardet<5,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests->Naked->Crypto) (4.0.0)
Note: you may need to restart the kernel to use updated packages.
It still shows the same after I restarted the kernel and even reinstalled the firebase module.

Python cant find module adbutils

I was using the adbutils package without any trouble. I restarted my pc and it doesn't work anymore. I get the error "No module named 'adbutils'". Which is very weird because it worked earlier and I am sure it is installed, I can straight up see the folder in my directory. Pip uninstalling and installing didn't work as well. I did get a lot of requirement not statisfied errors when reinstalling it. Other packages that are installed in the same directory do work without a problem. If anyone know why this is please let me know. Thank you
File "c:/Users/marti_wfv2bf9/Desktop/Python Projects/ADB testing/adb-testing.py", line 2, in <module>
import adbutils
ModuleNotFoundError: No module named 'adbutils'
PS C:\Users\marti_wfv2bf9\Desktop\Python Projects\ADB testing>
This is what I get when I try to reinstall it with pip3
pip3 install adbutils
Collecting adbutils
Using cached adbutils-0.8.1-py3-none-win_amd64.whl (1.4 MB)
Requirement already satisfied: apkutils2<2.0,>=1.0.0 in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from adbutils) (1.0.0)
Requirement already satisfied: whichcraft in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from adbutils) (0.6.1)
Requirement already satisfied: requests in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from adbutils) (2.23.0)
Requirement already satisfied: six in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from adbutils) (1.14.0)
Requirement already satisfied: deprecation<3.0,>=2.0.6 in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from adbutils) (2.1.0)
Requirement already satisfied: retry>=0.9 in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from adbutils) (0.9.2)
Requirement already satisfied: pyelftools in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from apkutils2<2.0,>=1.0.0->adbutils) (0.26)
Requirement already satisfied: cigam in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from apkutils2<2.0,>=1.0.0->adbutils) (0.0.3)
Requirement already satisfied: xmltodict in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from apkutils2<2.0,>=1.0.0->adbutils) (0.12.0)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests->adbutils) (2020.4.5.1)
Requirement already satisfied: idna<3,>=2.5 in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests->adbutils) (2.9)
Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests->adbutils) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests->adbutils) (1.25.8)
Requirement already satisfied: packaging in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from deprecation<3.0,>=2.0.6->adbutils) (20.4)
Requirement already satisfied: decorator>=3.4.2 in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from retry>=0.9->adbutils) (4.4.2)
Requirement already satisfied: py<2.0.0,>=1.4.26 in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from retry>=0.9->adbutils) (1.8.1)
Requirement already satisfied: pyparsing>=2.0.2 in c:\users\marti_wfv2bf9\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from packaging->deprecation<3.0,>=2.0.6->adbutils) (2.4.7)
Installing collected packages: adbutils
Successfully installed adbutils-0.8.1

Python locust not working in AWS instances

I am trying to use locust in ec2 instance for load testing of my project. So, I have installed locust using this command:
python -m pip install locustio
I got this below response:
Requirement already satisfied: locust in /usr/local/lib/python2.7/site-packages (0.0)
Requirement already satisfied: locustio in /usr/local/lib/python2.7/site-packages (from locust) (0.9.0)
Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python2.7/site-packages (from locustio->locust) (1.11.0)
Requirement already satisfied: msgpack>=0.4.2 in /usr/local/lib64/python2.7/site-packages (from locustio->locust) (0.5.6)
Requirement already satisfied: requests>=2.9.1 in /usr/local/lib/python2.7/site-packages (from locustio->locust) (2.19.1)
Requirement already satisfied: gevent>=1.2.2 in /usr/local/lib64/python2.7/site-packages (from locustio->locust) (1.3.6)
Requirement already satisfied: pyzmq>=16.0.2 in /usr/local/lib64/python2.7/site-packages (from locustio->locust) (17.1.2)
Requirement already satisfied: flask>=0.10.1 in /usr/local/lib64/python2.7/site-packages (from locustio->locust) (1.0.2)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python2.7/site-packages (from requests>=2.9.1->locustio->locust) (3.0.4)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /usr/local/lib/python2.7/site-packages (from requests>=2.9.1->locustio->locust) (1.23)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python2.7/site-packages (from requests>=2.9.1->locustio->locust) (2018.8.24)
Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/lib/python2.7/site-packages (from requests>=2.9.1->locustio->locust) (2.6)
Requirement already satisfied: greenlet>=0.4.14; platform_python_implementation == "CPython" in /usr/local/lib64/python2.7/site-packages (from gevent>=1.2.2->locustio->locust) (0.4.15)
Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python2.7/site-packages (from flask>=0.10.1->locustio->locust) (0.24)
Requirement already satisfied: Jinja2>=2.10 in /usr/local/lib/python2.7/site-packages (from flask>=0.10.1->locustio->locust) (2.10)
Requirement already satisfied: Werkzeug>=0.14 in /usr/local/lib/python2.7/site-packages (from flask>=0.10.1->locustio->locust) (0.14.1)
Requirement already satisfied: click>=5.1 in /usr/local/lib64/python2.7/site-packages (from flask>=0.10.1->locustio->locust) (7.0)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python2.7/site-packages (from Jinja2>=2.10->flask>=0.10.1->locustio->locust) (1.0)
I was thinking, locust is already installed. But when I execute my python script to start the server, it says below:
bash: locust: command not found
Can anyone please help me understand what's going wrong here? Thanks in advance.
ec2 instances don't necessarily install things in the usual directories.
I'd suggest running a command like:
find / -name locust 2>/dev/null
This will show you where locust has been installed (possible somewhere like /home/{user}/.local/bin)
Add this to your path (or whatever directory you found in the command above):
export PATH=$PATH:/home/{user}/.local/bin
After that your shell should be able to find the command.

Categories

Resources