Search found 734 matches: python

Searched query: +python

Return to advanced search

Re: Empty output for NLTK function

Problem solved. So i made few mistakes, and the correct code is:


#!C:\Users\HP\AppData\Local\Programs\Python\Python310-32\python.exe

import os
import urllib.parse
import nltk

query_dict = urllib.parse.parse_qs(os.environ[‘QUERY_STRING’])
input_something = str(query_dict[‘someamountoftext’])[2: -2]
def tknz_wrd(someamountoftext):
return(nltk.word_tokenize(someamountoftext))

print(“Content-Type: text/html\n”)

print (tknz_wrd(input_something))

It processes data, recieved from browser line, like: http://localhost/speciallocation/local/tokenize/morgot.py?someamountoftext=Enter%20your%20text%20here

morgot.py - name of CGI file.

'?someamountoftext=' This is how you enter data into variable

%20 - spacebar in browser line.
by stanislav
29. April 2022 11:05
 
Forum: XAMPP for Windows
Topic: Empty output for NLTK function
Replies: 1
Views: 2967

Empty output for NLTK function

Hi! I use python NLTK library in CGI script to tokenize some text in XAMPP web server. If i simply use:
someamountoftext = "someamountoftext someamountoftext someamountoftext" and then nltk.word_tokenize(someamountoftext) or nltk.sent_tokenize(someamountoftext) It will work.
BUT! If I use this:
import os
import urllib.parse
import nltk
query_dict = urllib.parse.parse_qs(os.environ['QUERY_STRING'])

def tknz_wrd(someamountoftext):
return(nltk.word_tokenize(someamountoftext))


print("Content-Type: text/html\n")
print (tknz_wrd)

It does not print anything on screen. No erros, just white browser screen.
I know it's not releted directly to apache, but maybe anyone encountered such problems before? Or I simply made some shamefully silly mistake......

I use: Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/7.4.28
python 3.10.4
by stanislav
25. April 2022 10:34
 
Forum: XAMPP for Windows
Topic: Empty output for NLTK function
Replies: 1
Views: 2967

Re: Python library "NLTK"

Thank you, very much, gsmith! It helped! Problem solved!
by stanislav
21. April 2022 09:31
 
Forum: XAMPP for Windows
Topic: Python library "NLTK"
Replies: 2
Views: 4073

Re: Python library "NLTK"

PassEnv APPDATA

Put it in httpd.conf if you want it available in all virtualhosts or inside any virtualhost you want APPDATA available for
by gsmith
19. April 2022 21:20
 
Forum: XAMPP for Windows
Topic: Python library "NLTK"
Replies: 2
Views: 4073

Python library "NLTK"

Hi guys! I need to use python library named "NLTK" on XAMPP. But as i found, NLTK "has platform-specific path handling"(https://stackoverflow.com/questions/16609242/import-nltk-not-working-on-xampp) and Apache does not provide the proper environment(https://stackoverflow.com/questions/11219319/appdata-is-not-returned-in-python-executed-via-cgi).
I hardly looked at the documentation and links above:
1) https://httpd.apache.org/docs/current/env.html
2) https://httpd.apache.org/docs/current/mod/mod_env.html#setenv
3) https://httpd.apache.org/docs/current/howto/cgi.html
"If your CGI program depends on non-standard environment variables, you will need to assure that those variables are passed by Apache." Thanks, very 'helpful'. I cant understand HOW and WHERE exactly I need to do env. fixes.
My configuration: Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/7.4.28 Server at localhost Port 80
I would be very grateful, if you give step-by-step instruction.

P.S. Sorry for bad english.
by stanislav
19. April 2022 12:42
 
Forum: XAMPP for Windows
Topic: Python library "NLTK"
Replies: 2
Views: 4073

Re: Python in XAMPP - Umgebungsvariable Userprofile fehlt

Davon konnte ich leider nicht viel verstehen. Welche Möglichkeit gibt es das Problem zu lösen?
by WaterIT
18. February 2022 14:20
 
Forum: XAMPP für Windows
Topic: Python in XAMPP - Umgebungsvariable Userprofile fehlt
Replies: 2
Views: 6980

Re: Python in XAMPP - Umgebungsvariable Userprofile fehlt

Mit dem Ort des Scripts hat das weniger zu tun.
Es gibt Benutzerbezogene Variablen und Systembezogene Variablen. Die Benutzerbezogenen Variablen beziehen sich auf den Benutzer, mit dem der Prozess läuft, also zum Beispiel der Apache httpd Daemon. Wird dieser als Windows Dienst gestartet läuft dieser Standardmäßig mit einem SYSTEM Rechten, nicht in einem Benutzerkontext.
by Altrea
18. February 2022 11:45
 
Forum: XAMPP für Windows
Topic: Python in XAMPP - Umgebungsvariable Userprofile fehlt
Replies: 2
Views: 6980

Python in XAMPP - Umgebungsvariable Userprofile fehlt

Hallo alle zusammen,

ich versuche Pythonscripte durch PHP Scripte zu verwenden. Das klappt auch alles ganz gut. Ich nutze XAMPP dazu. Jetzt habe ich aber folgenden Fehler:
Ich möchte gerne gmaps importieren. Er spuckt mir den Fehler aus: Exception: RuntimeError('Could not determine home directory.')

Wenn ich mit "print(os.environ)" mir die Umgebungsvariablen mit einer for-Schleife anzeigen lasse sehe ich folgende Umgebungsvariablen:

Code: Select all
MIBDIRS
MYSQL_HOME
OPENSSL_CONF
PHP_PEAR_SYSCONF_DIR
PHPRC
TMP
HTTPS
HTTP_HOST
HTTP_USER_AGENT
HTTP_ACCEPT
HTTP_ACCEPT_LANGUAGE
HTTP_ACCEPT_ENCODING
HTTP_CONNECTION
HTTP_COOKIE
HTTP_UPGRADE_INSECURE_REQUESTS
HTTP_SEC_FETCH_DEST
HTTP_SEC_FETCH_MODE
HTTP_SEC_FETCH_SITE
HTTP_SEC_FETCH_USER
HTTP_CACHE_CONTROL
PATH
SYSTEMROOT
COMSPEC
PATHEXT
WINDIR
SERVER_SIGNATURE
SERVER_SOFTWARE
SERVER_NAME
SERVER_ADDR
SERVER_PORT
REMOTE_ADDR
DOCUMENT_ROOT
REQUEST_SCHEME
CONTEXT_PREFIX
CONTEXT_DOCUMENT_ROOT
SERVER_ADMIN
SCRIPT_FILENAME
REMOTE_PORT
GATEWAY_INTERFACE
SERVER_PROTOCOL
REQUEST_METHOD
QUERY_STRING
REQUEST_URI
SCRIPT_NAME


Der Fehler kommt zustande, da in diesen Umgebungsvariablen kein "HOME" bzw in WIndows kein "USERPROFILE" enthalten ist. Ich glaube, dass der Grund ist, dass ich vom htdocs aus den Code starte. Dadurch zeigt der mir andere Umgebungsvariablen an als wenn ich den gleichen Code als normales Pycharm Projekt ausführe. Dann habe ich folgende Umgebungsvariablen:

Code: Select all
ALLUSERSPROFILE
APPDATA
COMMONPROGRAMFILES
COMMONPROGRAMFILES(X86)
COMMONPROGRAMW6432
COMPUTERNAME
COMSPEC
DRIVERDATA
FPS_BROWSER_APP_PROFILE_STRING
FPS_BROWSER_USER_PROFILE_STRING
HOMEDRIVE
HOMEPATH
IDEA_INITIAL_DIRECTORY
LOCALAPPDATA
LOGONSERVER
NUMBER_OF_PROCESSORS
ONEDRIVE
OS
PATH
PATHEXT
PROCESSOR_ARCHITECTURE
PROCESSOR_IDENTIFIER
PROCESSOR_LEVEL
PROCESSOR_REVISION
PROGRAMDATA
PROGRAMFILES
PROGRAMFILES(X86)
PROGRAMW6432
PROMPT
PSMODULEPATH
PUBLIC
PYCHARM COMMUNITY EDITION
PYCHARM_HOSTED
PYTHONIOENCODING
PYTHONPATH
PYTHONUNBUFFERED
SYSTEMDRIVE
SYSTEMROOT
TEMP
TMP
USERDNSDOMAIN
USERDOMAIN
USERDOMAIN_ROAMINGPROFILE
USERNAME
USERPROFILE
VIRTUAL_ENV
WINDIR

Hier ist Userprofile wieder enthalten.

Ich weiß nicht, was ich genau tun kann. Ich muss das Modul gmaps ungebingt importieren. Das will er aber nicht, weil er die Umgebungsvariable nicht findet. Gibt es eine Möglichkeit diese irgendwie hinzuzufügen?
by WaterIT
18. February 2022 11:18
 
Forum: XAMPP für Windows
Topic: Python in XAMPP - Umgebungsvariable Userprofile fehlt
Replies: 2
Views: 6980

PH-Messung (Wasser, Kaffee, u.s.w): DFRobot pH vs. EZO TM c

Hallo und guten Tag, liebe Community,


ich bin auf der Suche nach einem geeigneten Ansatz - bzw. einem Sensor für PH-Messung (Wasser, Kaffee, u.s.w): DFRobot pH vs. EZO TM class embedded pH circuit

Das Ziel: ich will zu Demonstrationszwecken den pH Wert bestimmen in den Getränken - Wasser, Kaffee, Mineralwasser, Tee.
Am liebten wäre mir, wenn ich das nicht kalibrieren muss - vor jeder Messung. M.a.W. ich suche ein einfaches u. robustes Verfahren - in Verbindung mit dem Einsatz von Raspi, Arduino oder ESP32

Vorweg: In der Chemie ist der pH-Wert eine Skala, die verwendet wird, um anzugeben, wie sauer oder basisch eine Lösung auf Wasserbasis ist. gut: Saure Lösungen haben einen niedrigeren pH-Wert, während basische Lösungen einen höheren pH-Wert haben.
Somit hat der pH-Sensor die Fähigkeit, den pH-Wert jeder Lösung zu bestimmen, d.h. er sagt, ob die Substanz sauer, basisch oder neutral ist.

Der Ph-Sensor hat ein breites Anwendungsspektrum wie Abwasserbehandlung, Pharmazeutika, Chemikalien und so weiter - oder schlicht nur die Messung von Werten im Aquarium.
Mein Ziel: Ich möchte einen pH-Sensor entwickeln, der hilft, den pH-Wert in Flüssigkeiten wie Kaffee, Wasser, Cola, Bier und dergleichen zu messen.
Ich möchte eine kostengünstige Lösung haben, eine, die - wenn möglich - auch ohne Kalibirierung auskommt. Ich dachte hier an mehrere Optionen:

DFRobot Gravity Analog pH vs. EZO TM class embedded pH circuit


Frage: Kann ich den Gravity Ph Sensor mit Arduino verbinden?

Ich möchte ein einfaches Ph-Messgerät erstellen und den Ph-Wert auf einem OLED / LCD-Display anzeigen. Ich denke, dass ich mit diesem Projekt viel lernen kann; Etwas über den Aufbau und die Funktionsweise des Ph-Sensors.
Last but not least - wenn das System kalibriert werden muss (was ich nicht unbedingt haben "muss" - dann würde ich das halt auch noch "mitnehmen".
M.a. W. Dann lerne ich die Kalibrierungsmethode, die die Richtigkeit und Genauigkeit des Sensors bestimmt.
Aber - wie gesagt: eigentlich will ich gerne um das Kalibrieren herumkommen.
Wenn es denn geht.





Freue mich von Euch kurz zu hoeren.

PS. - update:

Habe noch was zum Dfrobot gefunden. Der würde mir wohl auch ausreichen was die Genauigkeit anbelangt:

[URL unfurl="true"]https://eckstein-shop.de/DFRobotGravityAnalogpHSensor2FMeterKitForArduino[/URL]
zur Kalibrierung: vgl. https://community.dfrobot.com/makelog-308048.html



Zitat:

in this video is an overview and tutorial for an analog pH sensor that's >compatible with both Arduino and Raspberry Pi but I'll also give a general >overview of linear functions and interpolation. Plus I'll show you how to >write a custom code to use this sensor on an unsupported platform >(Espruino).
Measuring pH is pHun! (...I'm here all night folks.)

/* DF Robot Analog pH Sensor */

[URL unfurl="true"]https://www.dfrobot.com/product-1782.html[/URL]

Arduino Library: https://github.com/DFRobot/DFRobot_PH

Python Library: https://github.com/DFRobot/DFRobot_PH/t ... yPi/Python

/* DF Robot ADC Converter */ https://www.dfrobot.com/product-1730.html


Freue mich von Euch zu hoeren. VG
by unleash_it
19. January 2022 13:51
 
Forum: Allerlei
Topic: PH-Messung (Wasser, Kaffee, u.s.w): DFRobot pH vs. EZO TM c
Replies: 0
Views: 4581

Release of IPython 8.0 :: many new Features

Release of IPython 8.0 :: many new Features


https://blog.jupyter.org/release-of-ipy ... 034ff122ef

the authors on Jupyter.org just mentioned:

IPython is a powerful Python REPL that gives you tab completion, better tracebacks, multiline editing, and several useful features on top of pure Python Scripts. It is also the library that powers the Jupyter Kernel via the IPykernel.
Today I am pleased to announce the release of IPython 8.0, which has been long in the making and arrived a bit over three years after the 7.0 release. I also suggest to read the companion blog post on Quansight-Labs site that goes into some technical details on how we removed some old code. EDIT: You can also ask questions/comments on the jupyter discourse, or read the discussion on HN
Many new features
This major release comes with many improvements to the existing codebase and several new features. These new features are code reformatting with Black in the CLI, ghost suggestions, and better tracebacks which highlight the error node, thus making complex expressions easier to debug (see below).



head over to the page for more infos:

https://blog.jupyter.org/release-of-ipy ... 034ff122ef
by unleash_it
16. January 2022 23:40
 
Forum: Allerlei
Topic: Release of IPython 8.0 :: many new Features
Replies: 0
Views: 4005

XAMPP and Windows Subsystem for Linux

Hi!
I am on Windows 11 with XAMPP 3.3.0, and I use Debian on Windows Subsystem for Linux. I would like to use MySQL in XAMPP from WSL: is it possible?

More in detail, I develop a Python app in Flask (https://flask.palletsprojects.com/en/2.0.x/) which uses MySQL for database. I can launch the app from windows and it works fine, but when I launch it from Debian, it cannot connect to the database. The strange thing is that a few months ago it worked effortlessly, and now it does not work anymore. I have no idea what changed.
I could install mysql in Debian, but I liked that fact that I could use the same database from Windows and Debian for testing!

Thanks in advance!
Zep10
by zep10
11. January 2022 17:54
 
Forum: XAMPP for Windows
Topic: XAMPP and Windows Subsystem for Linux
Replies: 4
Views: 11632

pip and conda - where to use each of these options?

pip and conda - where to use each of these options?

ever wondered how where to use pip and where to use conda:

- pip is a package-manager for python packages.
- Conda on the other handside - it is a packaging tool and installer that aims to do more than what pip does; Yes - conda can do lots of other nice things too.

for example:
- it can also handle library dependencies outside of the Python packages as well as the Python packages themselves.
- it can create a virtual environment, like virtualenv does.

to sume up: Conda handles both Python and non-Python installation tasks. We also can have Conda packages for C libraries, or R packages, and many many more things - or simply: really anything.
long speech short sense: Conda is the package manager of Anaconda, but it can do lot more: it can be used outside of Anaconda too.

but the usage of Conda is interesting - but some developers use other tools: here some thoughts regarding the various tools:
well there are existing lots of tools that help us to manage virtual Python environments: Venv, pyenv, pipenv, poetry, and we have to mention here also Docker, and of course also virtualenv - and last but not least conda.

in the following we start with explanations on the different things: pip, PyPI, venv, pyenv, virtualenv, or any other....

let us start with pip:
pip: so what is pip. pip is just the Python Package Manager.
well, we might think of pip as the general python equivalent of the ruby gem command - it is pretty similar

- but wait: pip is not included with python by default.
we may install Python while using homebrew, which will install pip automatically: brew install python
besides this we can find and publish python packages using PyPI: The Python Package Index ( https://pypi.python.org/pypi )

pip: Python packages only: it compiles everything from source

from the docs:
Python Packaging User Guide ....[...]...the Python Packaging User Guide, a collection of tutorials and references to help you distribute and install Python packages with modern tools. This guide is maintained on GitHub by the Python Packaging Authority. We happily accept any contributions and feedback. ??
Get started
- Essential tools and concepts for working within the Python development ecosystem are covered in our Tutorials section:
- to learn how to install packages, see the tutorial on installing packages.
- to learn how to manage dependencies in a version controlled project, see the tutorial on managing application dependencies.
- to learn how to package and distribute our projects, see the tutorial on packaging and distributing
- to get an overview of packaging options for Python libraries and applications, see the Overview of Python Packaging.

The requirements.txt file is comparable to the ruby gemfile: To create a requirements text file, pip freeze > requirements.txt Note, at this point, we have python installed on our system, and we have created a requirements.txt file that outlines all of the python packages that have been installed on your system.

PyPI this packages is not in the standard library: virtualenv (see https://pypi.org/project/virtualenv/ ) is a very popular tool that creates isolated Python environments for Python libraries. It works by installing a bunch of files in a directory (eg: env/), and then modifying the PATH environment variable to prefix it with a custom bin directory (eg: env/bin/). see for more infos here: https://pypi.org/project/virtualenv/ and besides this cf: the documentation: https://virtualenv.pypa.io/en/latest/

cf: the documentation: https://virtualenv.pypa.io/en/latest/


here we want to shed a light on some of the most interesting Conda commands:

Well - if you ever installed Anaconda-distribution - you have some options:

- you can take the GUI installer,
- you can use the command-line-interface

Let’s look at common conda commands to create and manage conda environments.
Everything is the same whether you installed Anaconda or Miniconda.

imagine you want to create a conda environments:

Code: Select all
conda create -n my_env pandas [jupyterlab]


Create a new conda environment named myenv with the latest version of Python available on the main conda channel. and yes: if you whish to do it on Jupyterlab then you just have to add the following snippet) [ Install pandas and jupyterlab packages to the environment - just that easy]

you can do either:

Code: Select all
-n is short for --name


what it does: well in this case conda just asks you here for a concrete confirmation - in other words it asks for the confirmation with any of the above mentioned package changes that are in question. What do you have to do here: well you just have to do one thing: just hit an press y when youre asked whether you want to proceed this process.

can create a new conda environment, with program biopython with this:

Code: Select all
conda create --name munich-townhall


lets go ahead: What if you just do not want to install any program at all? in this case you can specify one or more default packages for the installation while you are just creating the environment. This is a great option doing so: in other words this allows you to call conda create without directly and explicitly providing any package name at all:


to to a setting of the provided packages, you just need to call conda config like so:

Code: Select all
    conda config --add create_me_the_default_packages_here: PACKAGE_NAME


and besides this you also can set (and choose) a package name of just "python" to get a base, empty install.


Code: Select all
conda create --name myenv python


# or just run this if you want to use some python version especially.

Code: Select all
conda create --name myenv python=3.7



here some more conda - commands that are used quite very very often:

conda info --envs : # this lists all environments
source activate <env name>: # this command activates an environment you want to use
conda env remove -n <env name> : # with this command you can delete an environment
conda env export > environment.yml:# export conda environment requirements list to a certain file
source deactivate: # and this command just deactivates an environment - try it out!
conda list : # with this command you just are able to list all packages installed on your system.
conda create --name <env name> python=3.9 : # with this you can create new environment, and yes: you of course can specify version of python;



see some great ressources for the usage of Conda: just have a closer look at the following pages:

https://gist.github.com/supriya-premkum ... cc79eef03b

https://github.com/conda/conda-build

https://gist.github.com/ctufts/fcd8bfaf ... 3bd4b52844

https://uoa-eresearch.github.io/eresear ... /20/conda/
Create virtual environments for python with conda :: How to set up a virtual environments using conda for the Anaconda Python distribution
by unleash_it
27. December 2021 11:42
 
Forum: Allerlei
Topic: pip and conda - where to use each of these options?
Replies: 0
Views: 4788

Access OSX ENV variables on XAMPP-VM

I'm trying to run a python script on a PHP script running on my XAMPP-VM Apache server but I am unable to access my python interpreter /usr/bin/python. My understanding is XAMPP uses its own ENV variables. How can I make my XAMPP-VM recognise my OS variables?
by Mariwa
05. November 2021 13:02
 
Forum: XAMPP for macOS
Topic: Access OSX ENV variables on XAMPP-VM
Replies: 1
Views: 4537

Re: How to publish my document online

A PC with a network card and an online connection.

A webserver software like Apache, Nginx etc

Probably a SQL Database.
Probably a server side interpreter like PHP, Perl, Python

A registrated Domainname, plus a Domain Name Server.

Knowledge about DNS configuration, actually quite difficult for a newcomer.
Knowledge about Webserver (Apache) configuration, also quite difficult for a beginner and a huge amount of knowledge.

Eventually a FTP Server. Also with knowledge about configuration.

Manpower in order to allow 24/7 connection, especially when the server shuts down due to errors or hackers.

All this and much more you can get at webproviders (there are plenty of these in the WWW) starting as low as 2 or 3 € per month. You get preconfigured webspace, full maintenance, unlimited traffic and at least one domain name of your choice. Already the costs of energie running your home based server will exceed the costs of rented webspace. I strongly recommend to go for a webprovider of your choice.
by Nobbie
28. October 2021 10:14
 
Forum: XAMPP for Windows
Topic: How to publish my document online
Replies: 3
Views: 4301

Re: Alias vs ScriptAlias

Wenn das da steht, wird das auch so sein, warum denn auch nicht? Das sieht auch nicht nach Xampp aus.

Die SCRIPT_ALIAS Anweisung hat auch mit PHP eigentlich direkt nichts zu tun, die benötigt man, wenn man CGI Scripts egal welcher Art (das kann auch Python sein, oder Perl, oder ein .exe aus einem C-Programm usw., oder eben auch PHP Scripte, WENN man PHP als CGI Mode installiert hat) In ein eigenes Verzeichnis auslagern will. Mit ALIAS werden alle Dateien dort gesucht mit der entsprechenden URL, unabhängig davon ob es ein CGI Script oder sonst etwas ist.

BRAUCHEN tut man SCRIPT_ALIAS eigentlich gar nicht mehr, es gibt genügend Möglichkeiten, CGI Scripts auch ohne diese Anweisung auszuführen.
by Nobbie
14. October 2021 08:23
 
Forum: Apache
Topic: Alias vs ScriptAlias
Replies: 4
Views: 15295
PreviousNext

Return to advanced search