I have little experience in Python and want to use this Python library to interface with an API: Python cPanel API library
However, it does not give me any instructions on how to install. I tried pip3 install -e git+https://github.com/vexxhost/python-cpanelapi#egg=cpanelapi gives me the error:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/src/cpanelapi/setup.py'
The repo contains a __init__.py, client.py and exceptions.py file.
How do I use and install this library?
Download the repository.
Move it to the base of your directory (along with your scripts)
Import it with import cpanelapi
Related
I want to import OpenBulletToPython library from GitHub So how do I do that? When I tried using pip install git+https://github.com/Categorically/OpenBulletToPython, I receive an ERROR: File "setup.py" not found for legacy project git+https://github.com/Categorically/OpenBulletToPython. So how can I import it??
Unfortunately the repository you linked to does not have a setup script.
So, you basically have to options:
Copy & Paste the code into the project where you want to use it (check the license before you do this)
Fork the repository and add a setup script yourself (as described here)
Hello I want to install a module named python-ldap locally in the same directory as my main so that it could be zipped and uploaded as a standalone function. The reason is AWS Lambda doesn't support installing this module (but i have installed it successfully on AmazonLinux). So I'm hoping i can install the module in an AmazonLinux instance and zip it so it runs on any instance. If its possible that is.
For example purposes i have a folder deploy-ldap with a single lambda_function.py inside.
The lambda_function.py simply imports the module like so:
import ldap
def main():
print("Success")
What I tried so far:
There are some resources on this suggesting to copy a single .so file but it didn't work for me and resulted in an error where another .so.2 file is being requested
Furthermore i tried installing the module with pip install python-ldap -t . but this also resulted in an error: "Unable to import module 'lambda_function': No module named '_ldap'"
All input appreciated, thank you. ^^
The import python-ldap is incorrect because module names in Python shouldn't contain dashes. The correct import as in the examples should be:
import ldap
Then to make it available in the environment of your AWS Lambda function, you should follow the same steps as documented in Deployment package with dependencies which consists of the following steps:
Prepare the file containing the code
Perform pip install python-ldap
Deploy the code along with the installation to AWS Lambda
I am having a lot of issues when uploading a PyPi package, because I have a package that reads information from a TXT file in another directory. This is my project structure:
I can read the files if I do it using my own package from the PyCharm project, but the problem is when I upload it to PyPi and I import is as a pip package.
I read the file in local this way:
tickers = pd.read_csv('../data/tickers.csv')
But that does not work when I install the package using pip.
I have been trying to configure setup.py, but with no succeed, because when I install the package uploaded to PyPi using pip, I get an error like this:
FileNotFoundError: [Errno 2] No such file or directory:
'data/user-agent-list.txt'
This is what I have in my setup.py related to those external files contained in the data/ directory:
I also have a MANIFEST.in to include the data files:
I hope the information I provided is enough for you to let me know how can I fix this... To give you extra information, I am following this tutorial to upload my package to PyPi, but the error has nothing to do with it.
Thank you!
I am wondering if the issue is not related to the path you are using here:
pd.read_csv('../data/tickers.csv')
It refers to the path that is relative to the base execution path of the script that is using your module. Try using a non-relative path. You may also want to use the install path as suggested in this question.
We are receiving an error:
ImportError: No module named OAuth2Client
We have noticed scores of questions around this topic, many unanswered and at least one answer that describes the solution of copying over files from the Google App Engine SDK.
This approach, however, seems tedious because all the dependencies are unclear. If we copy over oauth2client then run, the next error is another module that is missing. Fix that, then another module is missing, etc., etc.
What is ironic is that we can see all the files and modules needed, listed from Google App Engine SDK right in PyCharm but they seem inaccessible to the script.
Is there no better way to pull in all the files that oauth2client needs for Python to work on App Engine?
I have this problem and solved by installing oauth2client with pip3:
pip3 install --upgrade oauth2client
As per the google-api-python documentation, try this
pip install --upgrade google-api-python-client oauth2client
The answer is to "vendor" in the file(s).
We found a quick way to solve this based on this documentation https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring
and this SO answer.
Create a new folder called "lib" in the same folder as your app.yaml file. (You can name it something else. Just use that name below.)
Create an empty file called appengine_config.py in the same folder as your app.yaml file
Add two lines to that appengine_config.py file:
from google.appengine.ext import vendor
vendor.add('lib')
From terminal, navigate to the directory which contains that file and execute the following command:
sudo pip install -t lib google-api-python-client
The import error will disappear and you will have all the sub-dependent modules as well.
Install WHL file
pip install oauth2client-4.1.3-py2.py3-none-any.whl
Run this
sudo python -m pip install oauth2client
When I run a python script that I set up on WebJobs in Azure - I get the following error:
import MySQLdb
ImportError: No module named MySQLdb
job failed due to exit code 1
I found some articles that seem to suggest to install python modules to a directory created on the webapp. How/Where would I install those modules?
Have you tried this?
http://nicholasjackson.github.io/azure/python/python-packages-and-azure-webjobs/
(from the site):
Step 1.
If you are using OSX and the default Python 2.7 install your packages
installed with pip will be in /usr/local/lib/python2.7/site-packages,
create a folder called site-packages in the root of your python job
and copy any packages you need for your job into it.
Step 2
Next you need to modify your run.py or any other file which requires
access to the package files. At the top of the file add….
import sys
sys.path.append("site-packages")