How would I be able to configure EasyPHP to use the Python CGI? I have been trying to find information on this for the past while to no avail.
If you have Python 2.7 and EasyPHP 14.1 installed, you may go to the EasyPHP folder ../binaries/apache/cgi-bin/ (where, by the way, you may already have printenv.pl file which is the same stuff for Perl programming).
Create a .py file, let it be printenv.py, with the following content:
#!E:/Python27/python
# -*- coding: UTF-8 -*-
# enable debugging
import cgitb
cgitb.enable()
print "Content-Type: text/plain; charset=utf-8"
print
print "Hello World!"
(In my case E:/Python27/ is the folder where Python installed, so it shoud be changed accordingly.)
In a browser enter: 127.0.0.1/cgi-bin/printenv.py. (The localhost reference may differ but /cgi-bin/printenv.py part remains.)
Than you should see in your browser:
Hello World!
For more information, please, visit Web Python .
It is also recommended to use mod_wsgi instead of CGI technique.
Related
For some reason, the subtitles become the chapters in the PDF generated for my docs by ReadTheDocs.
Check it out here: https://yarsaw.namantech.me/_/downloads/en/latest/pdf/
Here's the code for the index file
######################
**Welcome to YARSAW!**
######################
YARSAW is an open source, free and easy to use API Wrapper for the `Random Stuff API`_.
***************
Overview
***************
Features:
* Wraps all of the `Random Stuff API <https://api-info.pgamerx.com>`_
* Async-ready
* Easy to use
* Saves you a lot of time
*****************
Installation
*****************
To install the latest stable version of YARSAW, run the following command:
.. code-block:: bash
python -m pip install yarsaw
To install a specific version of YARSAW, run the following command:
.. code-block:: bash
python -m pip install yarsaw==<version>
To install the beta version of YARSAW, run the following command:
.. code-block:: bash
python -m pip install git+https://github.com/BruceCodesGithub/yarsaw --upgrade
****************
Getting Started
****************
Get your API Keys
==================
1. Register to get an API Key at the `Random Stuff API resgistration page <https://api-docs.pgamerx.com/Getting%20Started/register/>`_. This is used for authentication.
2. Register at `RapidAPI <https://rapidapi.com/pgamerxdev/api/random-stuff-api>`_ for a RapidAPI Key and Account, and subscribe to the Random Stuff API. This is used to make requests to the Random Stuff API and keep track of them. You can go to `The RapidAPI Developer Dashboard <https://rapidapi.com/developer/apps>`_ after logging in, select an application, head over to security, and copy its key. This is your RapidAPI Key.
Examples
========
.. code-block:: python
import yarsaw
import asyncio # builtin, used for asynchronous calls
client = yarsaw.Client("your_api_key", "your_rapidapi_key")
async def joke():
joke = await client.get_joke() # get the joke in form of a dict
formatted_joke = yarsaw.Utils().format_joke(joke) # format the joke (optional)
print(formatted_joke) # print the joke
asyncio.get_event_loop().run_until_complete(joke()) # run the joke() function
Now just start reading the documentation!
****************
Contents
****************
.. tip::
The :doc:`client` page contains all of the methods you can use to interact with the Random Stuff API, so we recommend reading that first.
.. toctree::
:maxdepth: 1
:caption: Documentation
client
utils
.. toctree::
:maxdepth: 1
:caption: Other Pages and Resources
faq
changelog
Documentation Last Updated on |today|
I want Welcome to YARSAW to be the first chapter, the next file to be the next. Instead, the subtitles become the chapters, and all the other content becomes subtitle.
I followed convention syntax from https://readthedocs.org/projects/documentation-style-guide-sphinx/downloads/pdf/latest/.
It works fine on the docs page itself (https://yarsaw.namantech.me).
Changing heading signs does not work.
Full code: https://github.com/BruceCodesGithub/yarsaw
[SOLVED]
The problem was that the toctree was below headers, which caused issues. Moving to the top of the file solves it.
i have installed Saxon/C extension step by step, by this documentation: http://zf4.biz/blog/installing-the-saxon-c-php-extension
I must install it for PHP5, so this documentation was great. It all works fine and if i use this "php -m | grep saxon -i" command they shows me the extension:
PHP Warning: Module 'Saxon/C' already loaded in Unknown on line 0
Saxon/C
But in the phpinfo(); the extension is not listet on.
Anybody know why this dont works?
This bug issue is related to the issue #4151. The call to the method getUnderlyingValue() should take not arguments
On line 836 of the file php5_saxon.cpp please replace:
obj = ooth->xdmNode->getUnderlyingValue(NULL);
With the following:
obj = ooth->xdmNode->getUnderlyingValue();
Alternatively you can download the following file which contains the fix:
php5_saxon.cpp
You should then be able to build the Saxon/c extension for PHP5. Installation instructions given here http://www.saxonica.com/saxon-c/doc/html/index.html
I am current running on Debian 8 Jessie with Python 2.7 and the current google-cloud-speech and storage (pip'd in with upgrade today). When I attempt to config it fails with:
ValueError: Protocol message RecognitionConfig has no "enable_automatic_punctuation" field.
from this call:
config = speech.types.RecognitionConfig(
encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=8000,
language_code='en-US',
# Enable automatic punctuation
enable_automatic_punctuation=True)
The call was directly copy/paste'd from "https://cloud.google.com/speech-to-text/docs/automatic-punctuation#speech-enhanced-model-python".
Huh?
enable_automatic_punctuation is only available if you import speech_v1p1beta1 instead of speech_v1. Compare the documentation for RecognitionConfig for both beta and non beta.
Also, in the very same example that you have linked, if you click on View on Github, you can see the following import:
from google.cloud import speech_v1p1beta1 as speech
Also, related to this topic.
EDIT:
Also, that code is on Python 3, and you are using Python 2.7, be aware of that.
I started to learn Scrapy but I stuck up at weird point where I couldn't set default shell to ipython. The operating system of my laptop is Ubuntu 15.10. I also installed ipython and scrapy. They run well without causing any errors.
According to Scrapy's official tutorial, I can change my default scrapy shell by entering this in the global configuration file
[settings]
shell = ipython
The problem is I couldn't locate the configuration file. I tried following instructions from another page.
I made these three config files in
/etc/scrapy.cfg (system-wide),
~/.config/scrapy.cfg ($XDG_CONFIG_HOME) and ~/.scrapy.cfg ($HOME) for global (user-wide) settings.
but It didn't help at all.
what should I do?
I followed the instruction in the first answer by paul trmbrth. There still seems to be a problem though.
seems like I do have a right configuration file in the right place. But I still cannot open scrapy shell with ipython, as you can see in the screenshot. Have any idea?
Another way to configure (or test) the shell used by scrapy shell is the SCRAPY_PYTHON_SHELL environment variable.
So running:
paul#paul:~$ SCRAPY_PYTHON_SHELL=ipython scrapy shell
would use ipython as first choice, whatever setting in *scrapy.cfg you may have.
To check where scrapy is looking for config files, and what it finds, you can start the python interpreter and run what scrapy shell does:
$ python
Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from scrapy.utils.conf import get_config, get_sources
>>> get_sources()
['/etc/scrapy.cfg', 'c:\\scrapy\\scrapy.cfg', '/home/paul/.config/scrapy.cfg', '/home/paul/.scrapy.cfg', '']
>>> cfg = get_config()
>>> cfg.sections()
['deploy', 'settings']
>>> cfg.options('settings')
['shell']
>>> cfg.get('settings', 'shell')
'bpython'
If you are inside of the project you can use this:
from scrapy.utils.project import get_project_settings
settings = get_project_settings()
settings.get('IMPORT_API_URL')
If you are outside of the project, you can use this:
from scrapy.settings import Settings
settings = Settings()
settings_module_path = os.environ.get('SCRAPY_ENV', 'project.settings.dev')
settings.setmodule(settings_module_path, priority='project')
settings.get('BASE_URL')
I'm new to python and nltk. I have problem on import nltk.
I installed python in xampp on windows under the path C:\xampp\Python.
And I installed nltk under the path C:\xampp\Python.
After this I configured apache and run some sample python code, it worked well on the browser.
The URL is : /localhost/cgi-bin/test.py.
When I import the nltk in test.py its not running. The execution not continue after the "import nltk" line.
But when I run in the command prompt its working perfect.
Please let me know how to fix this issue.
Below is the sample code :
#!C:\Xampp\Python\python
print "Content-type: text/html\n\n"
import nltk
print "<html>"
print "<head>"
print "<title>This is test</title>"
print "</head>"
print "<body>"
print "This is paragraph"
print "</body>"
print "</html>"
I checked in the apache error log it look like below.
[Fri May 17 18:21:28.774308 2013] [cgi:error] [pid 2952:tid 1732] [client] AH01215: ValueError: Could not find a default download directory\r
I'm creating UI for nltk please help me. Thanks.
From looking at the code here, it appears that the library has platform-specific path handling and that error is thrown in the *nix branch. The code to detect Windows looks like this:
if sys.platform == 'win32' and 'APPDATA' in os.environ
I hope that sys.platform isn't getting messed up, so I think it's most likely that Apache isn't propagating the APPDATA environment variable down to your code.
This question explains why that is and gives a workaround.