Setup Python environment on Windows
How do I setup a Python environment on windows computer so I can start writing and running Python scripts, is there an install bundle? Also which database should i use?
I should of mentioned that I am using this for web based applications. Does it require apache? or does it use another http server? What is the standard setup for Python running web apps?
Asked by: Thomas188 | Posted: 28-01-2022
Answer 1
Download the Python 2.6 Windows installer from python.org (direct link). If you're just learning, use the included SQLite library so you don't have to fiddle with database servers.
Most web development frameworks (Django, Turbogears, etc) come with a built-in webserver command that runs on the local computer without Apache.
Answered by: Roland838 | Posted: 01-03-2022Answer 2
Bundle: go with Activestate's Python, which bundles many useful win32-related libraries. It has no version 2.6 yet, but most code you'll find online refers to 2.5 and lower anyway.
Database: any of the popular open-source DBs are simple to configure. But as John already suggested, for simple beginning stuff just use SQLite which already comes bundled with Python.
Web server: depends on the scale. You can configure Apache, yes, but for trying simple things the following is a quite complete web server in Python that will also serve CGI scripts writte in Python:
import CGIHTTPServer
import BaseHTTPServer
class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
cgi_directories = ["/cgi"]
PORT = 9999
httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
Answered by: Aldus631 | Posted: 01-03-2022
Answer 3
I strongly recommend ActiveState Python for python on windows development. It comes with Win32Com and various other goodies, has a mature and clean installer, a chm version of the docs and works really well. I use this all of the time.
As for a database, Activestate comes with odbc support, which plays very nicely with SQL server. I've also had it working with Sybase and DB2/400 (although the connection strings for the latter tend to be rather convoluted). For Oracle, I recommend CX_Oracle as the best interface library. Native drivers for most proprietary and open-source databases (such as MySQL and PostGreSQL) also exist. Recent versions of Python (from 2.5 onwards IIRC) come with SQLite bundled as standard.
Answered by: Brooke593 | Posted: 01-03-2022Answer 4
Don't forget to install pywin32 after installing the official (command line) installer. This will define additional start menu items and the highly useful PythonWin IDE.
An installer for both is available at Activestate (no 2.6 yet). The Activestate distribution contains additional documentation.
Answered by: Gianna862 | Posted: 01-03-2022Answer 5
Might I suggest taking a look at Karrigell? It's really a nice Python web framework if you don't require everything Django and Turbogears offers. It might be easier for you to work with web frameworks until you get comfortable with them.
For development, I recommend downloading the latest SPE IDE. It should provide you nearly all the tools you will need, plus it includes wxGlade for GUI development.
Answered by: Kevin334 | Posted: 01-03-2022Answer 6
Django tutorial How to install Django provides a good example how a web-development Python environment may look.
Answered by: Edgar749 | Posted: 01-03-2022Similar questions
windows - Python path in environment
I want to call a python script from batch script, but I dont want to hard-code path to python executable (python.exe) in my calling script.
e.g.
c:\python26\python.exe test.py
$PYTHONPATH\python.exe test.py
Is there any way to have PYTHONPATH like setting ?
python - How to read Windows file in Linux environment?
I'm trying to execute a Python program on Linux which I first created on Windows, but the following error is shown:
metadata = eval(metafile.read())
File "< string >", line 1
@
@
@
@
@
@
Any idea?
How to call python in PHP on windows environment
I need to call python program in php.I need to display the output in browser.
What are all setup i have to done to run python in php program on windows OS.
Please provide me some simple sample codes.I already went over many forums and questions,I cant understand How to perform this action exactly.Can anybody explain it to me briefly,so that i will have good understanding.I already went through functions such as
...
windows - Call batch from python - environment issues
I want to create a batch file using python, run that script and then execute more python code.
The batch script itself is simple, it just sets a few environment variables and launches an application with one argument. It looks similar to this:
@echo off
setlocal
set PROG=C:\foo\bar.cmd
set MYVAR1=PIRATES
set MYVAR2=NINJAS
set MYVAR3=KITTENS
set MYVAR4=LASERS
"%PROG%" "C:\foo\some_file"
endlocal
@ech...
How can I use my windows Python environment on Cygwin?
I have several packages on my windows python environment and I would like to use them inside Cygwin. Can I setup a virtual environment linked to the files used for the windows' python or do I have to copy the files?
python - Not able to run pybot batch file in cygwin in windows environment
I am running a shell script in cygwin where I am using python robot framework, but in that environment it's not getting 'pybot' as command.
$ pybot --version
Result-
-bash: pybot: command not found
However in cmd prompt the above command is working fine.
PS- I have already set python interpreter path in environment variable. As the same command is...
python - pyqt5 stop bug when I run my code at Windows 10 environment
I have a problem recently . I begin to use pyqt5 as my GUI . I find this problem and I couldn't find any information about it .OK here we Go .
I cannot ran this code .
from PyQt5 import QtCore, QtGui, QtWidgets
import cv2
import qimage2ndarray as q2n
from PyQt5.QtWidgets import QApplication , QMainWindow
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectNam...
python - conda environment from windows to linux
I have developed a project on windows using pycharm and I want to deploy in on an ubuntu server.
I am trying to create a requirements.txt using these commands:
conda list -e > requirements.txt
conda list > requirements.txt
Depending on the options the requirements.txt looks like any of these:
# This file may be used to create an envi...
python - How do I create Conda environment in Windows 10
I am trying to setup a conda environment in windows command promt so I can create a python discord bot but I get an error, I tried creating the environment in Anaconda prompt and it worked but pycharm didn't recognise it. How do I create the environment in windows promt so it is recognised by pycharm and so that when I import discord, it can be used normally. (Currently says there's no module named discord even though I in...
windows - How to run a Python script in a Conda environment from MATLAB?
I am writing a package to give to someone else so I am trying to make installation, dependencies, and use as simple as possible. The top-level calls for the package are in MATLAB but, at one point, I'd like to run a Python script from my MATLAB function. I don't know if the user will be on Unix or Windows. So far, I have used a Conda environment for my Python scripts because it uses specific versions of Scipy and Tensorflo...
windows - Python unable to acquire Oracle environment handle in Apache
I can run my django application using the developer server, but it does not run under apache. The error is:
Unable to acquire Oracle environment handle
Adding an ORACLE_HOME environment variable pointing to my 10g client did not fix the issue.
NOTE: the ORACLE_HOME did not end with a slash. Also, this is using the XAMPP version of Apache if that makes a difference.
windows - Python path in environment
I want to call a python script from batch script, but I dont want to hard-code path to python executable (python.exe) in my calling script.
e.g.
c:\python26\python.exe test.py
$PYTHONPATH\python.exe test.py
Is there any way to have PYTHONPATH like setting ?
python - How to read Windows file in Linux environment?
I'm trying to execute a Python program on Linux which I first created on Windows, but the following error is shown:
metadata = eval(metafile.read())
File "< string >", line 1
@
@
@
@
@
@
Any idea?
windows - How to execute batch file from Python so that it could alter environment of the calling process?
This question already has answers here:
How to call python in PHP on windows environment
I need to call python program in php.I need to display the output in browser.
What are all setup i have to done to run python in php program on windows OS.
Please provide me some simple sample codes.I already went over many forums and questions,I cant understand How to perform this action exactly.Can anybody explain it to me briefly,so that i will have good understanding.I already went through functions such as
...
windows - Set up Visual Studio command line build environment with python
I want to set up Visual Studio command line build environment with python so that I can use
subprocess.call(['msbuild', 'myapp.sln /p:Configuration=Release'])
to build my project with automation.
I have some other dependencies need to use a portable scripting language, so I chose python.
Is there any ways to do so? Thanks in advance.
Trial 1 (failure):
I tr...
windows - Call batch from python - environment issues
I want to create a batch file using python, run that script and then execute more python code.
The batch script itself is simple, it just sets a few environment variables and launches an application with one argument. It looks similar to this:
@echo off
setlocal
set PROG=C:\foo\bar.cmd
set MYVAR1=PIRATES
set MYVAR2=NINJAS
set MYVAR3=KITTENS
set MYVAR4=LASERS
"%PROG%" "C:\foo\some_file"
endlocal
@ech...
How can I use my windows Python environment on Cygwin?
I have several packages on my windows python environment and I would like to use them inside Cygwin. Can I setup a virtual environment linked to the files used for the windows' python or do I have to copy the files?
how to import .dbf file in python in windows environment?
can anyone tell me how to import a .dbf file in python . I am a beginner.
I have a .dbf file with me at local location. I need to do some operations on the record, using Python.
python - Not able to run pybot batch file in cygwin in windows environment
I am running a shell script in cygwin where I am using python robot framework, but in that environment it's not getting 'pybot' as command.
$ pybot --version
Result-
-bash: pybot: command not found
However in cmd prompt the above command is working fine.
PS- I have already set python interpreter path in environment variable. As the same command is...
gdb - Environment Variables in Python on Linux
Python's access to environment variables does not accurately reflect the operating system's view of the processes environment.
os.getenv and os.environ do not function as expected in particular cases.
Is there a way to properly get the running process' environment?
To demonstrate what I mean, take the two roughly equivalent programs (the first in C, the other in python):
#inclu...
linux - Python - Setting / Getting Environment Variables and Addrs
I need to set an environment variable in Python and find the address in memory where it is located. Since it's on Linux, I don't mind about using libraries that only work consistently on Linux (if that's the only way). How would you do this?
Edit: The scope of the problem is as follows: I'm trying to hack a program for class, and essentially I'm putting my shellcode into an environment variable and then overwriting...
python - Privilege Escalation in Web Environment for File Access
I have a situation where I would like to elevate the permissions I have in a web environment so that I can access a serial device.
The specific case is where I have a web interface for configuring a modem that comes up on /dev/ttyUSB[0-9].
Zero or more modems will be plugged in by an end user. I am writing some software that is capable of discerning which is a USB Wireless Modem by reading
How do I make environment variable changes stick in Python?
From what I've read, any changes to the environment variables in a Python instance are only available within that instance, and disappear once the instance is closed. Is there any way to make them stick by committing them to the system?
The reason I need to do this is because at the studio where I work, tools like Maya rely heavily on environment variables to configure paths across multiple platforms.
My t...
Running unit tests with Nose inside a Python environment such as Autodesk Maya?
I'd like to start creating unit tests for my Maya scripts. These scripts must be run inside the Maya environment and rely on the maya.cmds module namespace.
How can I run Nose tests from inside a running environment such as Maya?
Safe Python Environment in Linux
Is it possible to create an environment to safely run arbitrary Python scripts under Linux? Those scripts are supposed to be received from untrusted people and may be too large to check them manually.
A very brute-force solution is to create a virtual machine and restore its initial state after every launch of an untrusted script. (Too expensive.)
I wonder if it's possible to restrict Python from accessing ...
django - Python learning environment
I'm looking to get up to speed on Python:
Is it worth working locally via the ActivePython interface, then progressing to a website that supports one of the standard frameworks (Django or Pylons) OR utilize the Google Apps environment?
I want to stay as interactive as possible - making feedback/learning easier.
Python Environment Variables in Windows?
I'm developing a script that runs a program with other scripts over and over for testing purposes.
How it currently works is I have one Python script which I launch. That script calls the program and loads the other scripts. It kills the program after 60 seconds to launch the program again with the next script.
For some scripts, 60 seconds is too long, so I was wondering if I am able to set a FLAG variable ...
python - Error on connecting to Oracle from py2exe'd program: Unable to acquire Oracle environment handle
My python program (Python 2.6) works fine when I run it using the Python interpreter, it connects to the Oracle database (10g XE) without error. However, when I compile it using py2exe, the executable version fails with "Unable to acquire Oracle environment handle" at the call to cx_Oracle.connect().
I've tried the following with no joy:
Oracle instant client 10g and 11g
Oracle XE Client...
apache - Python + CGI script cannot access environment variables
I'm coding a webservice on python that uses an Oracle database. I have cx_Oracle installed and working but I'm having some problems when I run my python code as CGI using Apache.
For example the following code works perfectly at the command line:
#!/usr/bin/python
import os
import cx_Oracle
import defs as df
os.putenv('ORACLE_HOME', '/oracledb/10.2.0/')
os.putenv('LD_LIBRARY_PATH', '/oracledb/...
Still can't find your answer? Check out these communities...
PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python