Running Travis-CI off of github - python

I have a Windows machine so I' trying to have Travis CI run my python scripts directly from github. Is it possible to run Travis CI python scripts directly from my github and not from my local repository?

You can integrate TracisCI to your GItHub repo
That way, on each push, your associated TravisCI job will run and execute what you have specified.
Regarding your travis.yaml, it has to respect the yaml syntax format:
language: python
sudo: enabled
python:
-"3.5" <========= incorrect: must be - "3.5"
See Building a Python Project: you will see a space between - and "x.y" version.
Regarding the unittest error, see "unittest installation error Could not find a version that satisfies the requirement"
unittest is a standard module, which you don't need to install.

Related

ERROR: Could not find a version that satisfies the requirement azure-functions

I have been doing this exercise:
Create a function in Azure using Visual Studio Code
https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-vs-code?pivots=programming-language-python
After doing the following steps:
Select a language for your function project: Choose Python.
Select a Python alias to create a virtual environment: Choose the location of your Python interpreter. If the location isn't shown, type in the full path to your Python binary.
Select a template for your project's first function: Choose HTTP trigger.
Provide a function name: Type HttpExample.
Authorization level: Choose Anonymous, which enables anyone to call your function endpoint. To learn about authorization level, see Authorization keys.
Select how you would like to open your project: Choose Add to workspace.
I press F5 to Run the function locally
And this is the error I get:
I have python, pip, wheel, azure-function tools installed
PS C:\Users\Mustafa Saifee\azfunc> python --version
Python 3.8.2
PS C:\Users\Mustafa Saifee\azfunc> pip --version
pip 20.1 from c:\program files\python38\lib\site-packages\pip (python 3.8)
PS C:\Users\Mustafa Saifee\azfunc> wheel version
wheel 0.34.2
PS C:\Users\Mustafa Saifee\azfunc> pip install azure-functions
Requirement already satisfied: azure-functions in c:\program files\python38\lib\site-packages (1.2.1)
Operating System: Microsoft Windows 10 Education 10.0.19041 Build 19041
How do I get this problem solved? Please help
Tried this as well:
I tried python 3.7 and 3.8
plus I also tried it with the conda based python.
Then I uninstalled everything. And one by one installed it back. Still the issue persists
I just want that error gone so that I can complete the rest of the exercise.
(I have posted this issue on my GitHub Repository as well if incase you can tag someone from the #azure-functions team on my GitHub Issue)
#aprilspeight helped me solve this issue. So this issue can be closed.
The solution is given by #aprilspeight: Have you tried running
the function while the init.py file is active on the screen?
There shouldn't be a need to modify anything in the function.json file
if you're trying out the Quickstart. Therefore, ensure that you're
looking at the init.py file when you Start Debugging (F5).
The whole issue can be read HERE

How do you get mypy to recognize a newer version of python?

I just updated my project to Python 3.7 and I'm seeing this error when I run mypy on the project: error: "Type[datetime]" has no attribute "fromisoformat"
datetime does have a function fromisoformat in Python 3.7, but not in previous versions of Python. Why is mypy reporting this error, and how can I get it to analyze Python 3.7 correctly?
Things I've tried so far:
Deleting .mypy_cache (which has a suspicious looking subfolder titled 3.6)
Reinstalling mypy with pip install --upgrade --force-reinstall mypy
To reproduce:
Create a python 3.6 project
install mypy 0.761 (latest) in the project venv
scan the project with mypy (mypy .)
update the project to python 3.7
add a file with this code in it:
from datetime import datetime
datetime.fromisoformat('2011-11-04 00:05:23.283')
scan the project again (mypy .) [UPDATE: this actually works fine. It was rerunning my precommit hooks without reinstalling pre-commit on the new Python version venv that was causing the problems.]
You are running mypy under an older version of Python. mypy defaults to the version of Python that is used to run it.
You have two options:
You can change the Python language version with the --python-version command-line option:
This flag will make mypy type check your code as if it were run under Python version X.Y. Without this option, mypy will default to using whatever version of Python is running mypy.
I'd put this in the project mypy configuration file; the equivalent of the command-line switch is named python_version; put it in the global [mypy] section:
[mypy]
python_version = 3.7
Install mypy into the virtualenv of your project, so that it uses the exact same Python version.
Note that if you see this issue (and didn't accidentally set --python-version, on the command-line or in a configuration file, you are certainly not running mypy from your project venv.
The solution was simple: simply run mypy with the --python-version flag. so in my case it was --python-version=3.7.
If you use pre-commit, you can also add this as an argument in a precommit check in your .pre-commit-config.yaml. Mine looks like this:
repos:
...
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.750 # Use the sha / tag you want to point at
hooks:
- id: mypy
args: [--python-version=3.7]
If you run mypy often from the command line you can also add it to a config file as described herehttps://mypy.readthedocs.io/en/stable/config_file.html.
Another note: if mypy is reporting errors when your pre-commit hooks run, but not when it is run by itself from the project venv, then you need to either
add python-version as an argument like I do above, or
reinstall pre-commit in the new project venv (with the correct python version)

How do i install a Prject interpeter that cannot be found in the pycharm explorer

I am trying to install the huobi_python lib to my pycharm however i'm unable to do so. I have tried multiple times to add it and google it but did not succseed. Does anyone know how to fix this?
Github link:https://github.com/huobiapi/huobi_Python
Running windows 10, no i cannot find it in Project interpeter and with the + sign. Those are mostly REST api's
You wouldn't add it as an interpreter.
Since the project isn't available as pip install, you'd have to build it from source. Meaning clone the repo, and run the command listed in the installation section from the command prompt. Also make sure that you're using Python3.7, as listed there.
Your interpreter then would have to just be Python 3.7, which will allow you to import the modules from other Python code
from huobi import RequestClient
# your code

How to use lxml version 3.7.3 on app engine?

On their Built-in Third-party Libraries page, it says that lxml 3.7.3 is supported but I can't seem to find a way to use that.
If I write in app.yaml:
- name: lxml
version: latest
When I log etree.LXML_VERSION inside the app, I get (2, 3, 0, 0).
Setting the version specifically to "3.7.3" (instead of latest) doesn't seem to work. When I try to deploy, gcloud says:
ERROR: (gcloud.app.deploy) An error occurred while parsing file: [... /app.yaml]
lxml version "3.7.3" is not supported, use one of: "2.3", "2.3.5"
in "... app.yaml", line 17, column 1
I have installed lxml locally inside the ./lib folder, but the folder is ignored on deploy.
Am I doing something wrong?
The problems seemed to happen because of an old google cloud sdk.
The sdk was installed using apt-get and somehow it was not getting updated. This also included an older Python SDK
At this moment the latest Python SDK is 1.9.62, I was using 1.9.52.
Updating the sdk seemed to fix the problem
sudo apt-get update && sudo apt-get install google-cloud-sdk
It wouldn't be the 1st time that inconsistencies exist between the documentation, what's included in the cloud SDK, what's included in the GAE language specific SDK and what's actually available on GAE (in production). See, for example, PyCharm - Can't create App Engine Application using DJango.
The deployment error message you got suggests that the 3.7.3 version doesn't actually exist on GAE, despite being marked as available in the documentation.
The lxml library is on the list of a few special libraries which need extra attention. Most likely because they aren't "pure Python code with no C extensions" and thus they can't be included in the SDKs with the other libraries, so they need to be installed separately on your local system. From Using built-in bundled libraries with the local development server (check that entire section for related info):
Many of the built-in libraries provided by the runtime are
automatically available to the local development server. However, the
following built-in libraries must be installed locally before you can
use them with the local development server:
lxml
matplotlib
mysqldb
numpy
PIL
crcmod
pycrypto
Now, if you really want the 3.7.3 version, you may be out of luck: if indeed it's not "pure Python code with no C extensions" then you also won't be able to vendor it into your app either. Still, it's worth a try. A new try, note that you also need to:
take it out of the app.yaml file's libraries: section - you're not requesting a GAE-provided library anymore
complete the entire vendoring in procedure (you didn't mention creating the appengine_config.py file, for example).
If that doesn't work then you'll have to settle for one of the available versions mentioned in the deployment error messages. You'll need to:
add that version to the app.yaml file's libraries: section
install that version on your local system
drop the vendoring in attempt, if you went for it

Does google app engine use python 2.7.0 or 2.7.1?

What python version does app engine use?
This is related to problems I'm having on mac osx with getting pycrypto to work. Because the python version now in mac is 2.7.1. When Google says the python version for app engine is '2.7' do they mean precisely 2.7.0? Or is python 2.7.1 okay too?
Can this cause problems for my local install of pycrypto? ( which I installed with pip: sudo pip install pycrypto==2.6 )The pycrypto library works correctly, but it somehow messes up app engine running a development server. The logging doesn't show all errors or logs which I expect to appear there.
When Google says the python version for app engine is '2.7' do they mean precisely 2.7.0? Or is python 2.7.1 okay too?
Any subversion of python 2.7 works. 2.7.0 works, but I have used 2.7.6 and 2.7.10 extensively as well. So I'm sure that 2.7.1 will work too.
Can this cause problems for my local install of pycrypto? ( which I installed with pip using: 'sudo pip install pycrypto==2.6' )The pycrypto library works correctly, but it somehow messes up app engine running a development server. The logging doesn't show all errors or logs which I expect to appear there.
I know you have asked about this before but I will give you an other (better) way to include pycrypto in your appengine project.
In your app.yaml, specify the following:
libraries:
- name: pycrypto
version: "2.6" # or "latest", or "2.3"
See https://cloud.google.com/appengine/docs/python/tools/libraries27 for more info about which libraries are supported by appengine and how you can import which versions.
It seems as though you're asking the question which inspired your title, about python verson 2.7.x, as a way to get insight into your actual problem, which is related to pycrypto. Tim's answer dealt with the question of which sub-versions of 2.7.x are supported.
It appears you're using both the app.yaml libraries stanza and pip to get an instance of pycrypto. So:
Is the pip-installed pycrypto residing on your dev-box somewhere like /usr/local/lib/python-2.7, or is it in the app's folder, specifically?
When the dev-server is running, is it possible your python path has it using the pycrypto installed by pip on your system, with that pycrypto being a different version than the one in production? This might cause different behaviour on the dev-server vs. production.
...All this said, it still seems odd, as Tim has pointed out, that you should see a disruption to logging based on this. What is it you're logging, and are you using any exception handling which might be dropping the responsibility to log?
Finally, is there a setting when running the dev-server which you can use that would enable more verbosity? Try that to see if you can raise the logging level enough to make the exceptions you're looking for visible.
These are my thoughts so far on how to get out of your jam.

Categories

Resources