Hello Python C-experts.
I'm trying to embed python27.dll in a C-program written in
MingW-gcc 4.7.2. I've successfully done these initial steps:
typedef int (*Py_Main_t) (int argc, char **argv);
handle = LoadLibrary (python27.dll);
py_main = (Py_Main_t) GetProcAddress (handle, Py_Main);
Chris Angelico ros...@gmail.com wrote:
There are a few Python DNS modules. It means adding another
dependency, but perhaps not as large as twisted. And of course, you
could always manually send UDP packets and listen for responses, but
that seems a little unnecessary :)
Then there is pycares;
Michael Schwarz michi.schw...@gmail.com wrote:
So how do I run my code so it will find the built extension module? Do I
pass the output directory on the command line manually or is there some
other solution? I would like to still be able to run the code from the
source directory as I'm using
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
If myVar is a Unicode string, you don't need to care about the encoding
(UTF-8 or otherwise) until you're ready to write it to a file. Then I
strongly recommend you always use UTF-8, unless you have to interoperate
with some old,
Hello list. I'm a newbie when it comes to Python.
I'm trying to turn this:
def print_sys_path():
i = 0
for p in sys.path:
print ('sys.path[%2d]: %s' % (i, p))
i += 1
into a one-line python command (in a .bat file):
python -c import sys,os; i=0; for p in sys.path:
Dave Angel d...@davea.name wrote:
it has nothing to do with being on a command line. You're using
semicolon to combine several statements, and there are restrictions on
what can be combined that way. One restriction is the looping
constructs, for, if, while.
Ok, I suspected something like
wxjmfa...@gmail.com wrote in comp.lang.python
(my ISP no longer updates this group. Last message is from 8. April.
Does the postings to the python mailing-list automatically get reposted
to comp.lang.python?)
C:\Windows\system32\python32.zip
c:\python32\DLLs
I see a similar result:
Dave Angel d...@davea.name wrote:
Why would you write some C-program just to save having two separate
files, one batch and one for the script? For that matter, several
answers have given you approaches that didn't involve list
comprehensions, including merging the two in a single file, using
Tim Golden m...@timgolden.me.uk wrote:
In general, you'll want to be using a mechanism such as pip:
http://pypi.python.org/pypi/pip
which will look things up on PyPI so you can just do pip install
newmodule.
And if you have a pip.bat from some Perl installation sitting before
python's
Smaran Harihar smaran.hari...@gmail.com wrote:
i found pycurl to execute python curl command but not sure how I can
execute the curl command using the pycurl.
curl -u admin:geoserver -v -XPUT -H 'Content-type: text/plain' -d
'file:/var/www/geo/shapefile/csvQshp/Quercus_iltisii.shp'
Isaac Won winef...@gmail.com wrote:
while c 10:
c = c + 1
for columns in ( raw.strip().split() for raw in f ):
b.append(columns[c])
y = np.array(b, float)
print c, y
I thought that can get the arrays of the columns[5] to [10],
but I only could
Chris Angelico ros...@gmail.com wrote:
I agree in general, but I happen to be pretty familiar with Mailman
alerts, and this one was genuine. Also, it pointed to what does appear
to be the right address (mail.python.org). There's definitely
something going around that's causing problems for
Gisle V.
Computers are useless. They can only give answers --Pablo Picasso
Chris Angelico ros...@gmail.com wrote:
For SQL? Ignore the extra spaces, it's a free-form language. The only
reason to consider dedent() would be if you're worried about how your
log files will look. The actual
Walter Hughey wkhug...@gmail.com wrote:
Thank you for your reply. One quick question, when
I reply should it be replay to all or to the person who sent the emial?
When replying, the most important thing to remember is... order.
A: Because it messes up the order in which people normally read
Grant Edwards wrote:
Not *any* computer? Not in *any* way? The Python built-in float
type works with the set of real numbers, in a way.
The only people who think that are people who don't actualy _use_
floating point types on computers.
FPU parsing the IEEE spec, or?. I didn't quite parse
In http://docs.python.org/faq/gui.html I came across
FOX Toolkit and the binding FXPy. The latter, it seems
is no longer officially supported (hasn't for the last 7-8
years). So my question. Has anybody to your knowledge
tweaked FOX and FXPy to work with Python 2.7?
--gv
--
Chris Angelico ros...@gmail.com wrote:
The only other time I've been waiting for X display was when I was
mobile, on a 3G connection, and using X11 forwarding on an SSH link
back to my home LAN.
Doing X11 calls over a network could really be a nuisance for others. And
an archaic design
Artur Bercik vbubbl...@gmail.com wrote:
I have to set several variables so it would be easier if I could set them
from Python.
You can write a Python-script that generates a .bat file (in your %TEMP-dir?).
And run this .bat file when Python ends. Put it all in an alias or another .bat
file.
Wayne Werner wa...@waynewerner.com wrote:
Yep. That's how I feel. I had used ViEmu in Visual Studio for coding in .NET at
work - but I found that the buffers macros were more powerful. So now I do
most of my programming in Vim, and only head to VS if I need autocomplete or
some of it's
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
py from timeit import Timer
py t1 = Timer((a**b)*(c**d), setup=a,b,c,d = 10, 25, 2, 50)
py min(t1.repeat(repeat=5, number=10))
0.5256571769714355
So that's about 5 microseconds on my (slow) computer.
That's pretty fast. So is
jkn jkn...@nicorp.f9.co.uk wrote:
I have to write python code which must run on an old version of
python (v2.4) as well as a newer (v2.7). I am using pylint and would
like to check if is possible to check with pylint the use of operators
etc. which are not present in 2.4; the ternary
Here is something interesting that you pythonistas might be
interested in:
http://www.primaryobjects.com/CMS/Article149.aspx
This article describes an experiment to produce an AI program, capable of
developing its own programs, using a genetic algorithm implementation with
self-modifying
Chris Angelico ros...@gmail.com wrote:
That's not artificial intelligence, though. It's artificial program
generation based on a known target output. The Fitness calculation
is based on a specific target string. This is fine for devising a
program that will produce the entire works of
Marwan Badawi marwan.bad...@inria.fr wrote:
I just noticed that my reply went to the message sender and not to the
newsgroup, so I'm posting again: thanks, I'll look into that.
Yes, I often do that too; i.e. I'm subscribed to python-list@python.org
and get all messages from comp.lang.python
Are anyone aware of a tool that can show me at run-time
which modules (pyd/dll) are loaded into a Python program
at a specific time (or over time)?
To clarify, e.g. when running a sample from PyQt4
(examples\tutorials\addressbook\part1.pyw) and using Process Explorer [1],
I can launch WinDbg
Ken Stewart wrote:
Here is a sample key:
S1-5-21-1560217580-722697556-320042093-1000-Classes
py_auto_file
shell
open
command
The corrected data for the key looks like this:
C:\Python34\python.exe %1 %*
Yikes! You use the awful cmd.exe as the shell
Ian Kelly wrote:
I checked my own Python 2.7 installation and discovered that I have
the same problem, although without the different casing. Perusing the
.pth files in site-packages turns up setuptools.pth, which just
contains the site-packages path. Removing that file solves the issue
for me.
(sys.path)] | sort --ignore-case
which produces:
f:\Documents and Settings\Gisle
Vanem\Programdata\Python\Python27\site-packages
f:\windows\system32\python27.zip !! doesn't exist, but okay.
G:\Programfiler\Python27
g:\Programfiler\Python27\DLLs
g:\Programfiler\Python27\lib
g
I tried using Interactive Python with a PyQt4 console:
IPython.exe qtconsole
But got a
ImportError: IPython requires PyQT4 = 4.7, found 4.10.4
Looking at Ipython's check (in site-packages\IPython\external\qt.py):
if QtCore.PYQT_VERSION_STR '4.7':
raise ImportError(IPython requires
Tim Chase wrote: So the test should actually be something like
if LooseVersion(QtCore.PYQT_VERSION_STR) LooseVersion(4.10):
balk()
That's exactly what they do now in IPython/utils/version.py with
the comment:
Utilities for version comparison
It is a bit ridiculous that we need
Dave Angel wrote:
When I ran Windows, I had written a simple utility that searched the PATH for a
specified file.
I called it which.bat to match the Linux equivalent.
I've written a similar tool; envtool --path --python python27.dll
Matches in %PATH:
15 May 2013 - 21:43:38:
Dave Angel wrote:
Finally, when py.exe starts, it reads that first (shebang) line, and decides
which python interpreter to actually use.
py.exe? Do you mean python.exe?
Is there a way to make python.exe ignore all Shebang lines
in all scripts? I had many generated .py-files with:
Cecil Westerhof wrote:
If I execute:
l = range(int(1E9)
The python process gobbles up all the memory and is killed. The
problem is that after this my swap is completely used, because other
processes have swapped to it. This make those programs more slowly. Is
there a way to circumvent
Chris Angelico wrote:
There's a specific search order. Back in the days of DOS, it was
simply com, then exe, then bat, but on modern Windowses, I think
it's governed by an environment variable.
You probably mean '%PATHEXT'. Mine is:
I just installed the 32-bit Python 3.5b4 via the Web-installer.
First, I was a bit annoyed by the fact it installed under
'f:\ProgramFiler-x86\Python35' instead of
'f:\ProgramFiler\Python35' as I customided for. But I guess
this is a WOW64 thing. I'm on Win-8.1 (64-bit).
But then I noticed
Zachary Ware wrote:
Is there any particular reason you're setting PYTHONHOME in the first
place?
I have several GNU Makefiles that picks up this variable
(to find Python.h, python*.lib etc.). But using Python 27
and 35 w/o having a %PYTHONHOME set, seems to work fine.
I have to revise those
I've written a C-program that embeds Python 2.7.
It has worked fine for several years using MingW or MSVC. Now I'd like
to support the python2.7.exe that comes with CygWin64.
But it seems to fail inside 'Py_InitializeEx(0)' where it just prints:
ImportError: No module named site
What? Does
"Peter Brittain" wrote:
I have recently been working on a terminal/console animation package
(https://github.com/peterbrittain/asciimatics).
I tried installing your package with "pip.exe -v install asciimatics".
Some problem with pypiwin32 it seems:
Installing
Mark Lawrence wrote:
CPython's Windows support now follows this lifecycle. A new feature
release X.Y.0 will support all Windows releases whose extended support
phase is not yet expired. Subsequent bug fix releases will support the
same Windows releases as the original feature release (even if
"Chris Angelico" wrote:
Ah, that might well be it. Does it work if you run:
python -S -m pip install --upgrade win32api
Hm.
c:\>python2 -S -m pip install --upgrade win32api
Collecting win32api
Could not find any downloads that satisfy the requirement win32api
No
"Chris Angelico" <ros...@gmail.com> wrote:
On Thu, Oct 22, 2015 at 10:22 PM, Gisle Vanem <gva...@yahoo.no> wrote:
IOError: [Errno 13] Permission denied:
'g:\\Programfiler\\Python27\\Lib\\site-packages\\win32\\win32api.pyd'
-
BTW, this is on Python 2.7.9 on Win-XP
eryksun wrote:
Here's a slightly simpler way to open the folder:
py -3.5 -c "import os, sys; os.startfile(sys.prefix)"
And what to do if the Pylauncher itself seems confused or the
Registry settings for PythonCore is messed up? The WOW64 mess
MS has have seems to have caused some
eryksun wrote:
The version of py.exe distributed with Python 3 is a 32-bit
application, so when the debug output says it's looking in the
"native" registry, it's referring to the WOW64 redirected registry
path, i.e. "HKLM\Software\Wow6432Node\Python". If py.exe can't find
your installation of
Gilad Mayani wrote:
I always get this message:
the program can't start because api-ms-win-crt-runtime-I1-1-0.dll is
missing from your computer.
Is that really an 'I' in there? The .dll should really
be named:
%SystemRoot%\system32\api-ms-win-crt-runtime-l1-1-0.dll
with an lower-case
Cameron Simpson:
> You might also want to check that the interface is up.
>
> My personal hack (not for a VPN, but for "being online", which turns my ssh
> tunnels on and off) is to look in the output
> of "netstat -rn" for a default route. This may imply that an alternative test
> for you is
Dennis Lee Bieber wrote:
>>> How can one search for files with DOS?
>>
>> dir /s /b \*add2path.*
>>
>> ChrisA
>
> Or move to PowerShell...
>
> Windows PowerShell
> Copyright (C) 2009 Microsoft Corporation. All rights reserved.
>
> PS C:\Users\Wulfraed\Documents> Get-ChildItem -Path c:\
Greg Tibbet wrote:
ellipse() uses the method self.draw.draw_ellipse() Okay, fine...
but WHERE is draw_ellipse defined?? What magic is happening there?
I've searched the entire PIL directory tree, and the ONLY two places
draw_ellipse is mentioned are right there in the ellipse() function...
Lele Gaifax wrote:
On my PC, I get the following, using the "-v" option to verbosely see the
imported modules:
$ $ python -v
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
...
import life
dlopen("./life.so", 2);
import life # dynamically loaded from life.so
bartc wrote:
From inside python 2.7:
Python 2.7.13rc1 (v2.7.13rc1:4d6fd49eeb14, Dec 3 2016, 21:49:42) [MSC
v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import life
>>> dir(life)
['__builtins__', '__doc__',
Lele Gaifax wrote:
$ python setup.py build_ext --inplace
Compiling life.pyx because it changed.
[1/1] Cythonizing life.pyx
running build_ext
building 'life' extension
creating build
creating build/temp.linux-x86_64-3.6
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall
I have trouble understanding why a 'sys.exit(2)' is
*not* passed back to the CMD shell in this little example:
- c:\py_cmd_test.cmd --
@%WinDir%\py.exe -2 -x %~dp0py_cmd_test.cmd & exit /b %ERRORLEVEL%
# The '-x' is for Python to skip the 1st line of this file.
import sys
print ("Hello,
Barry Scott wrote:
Here is an example:
from colour_text import ColourText
ct = ColourText()
ct.initTerminal()
print( ct( "The next section is in green: <>green example<>." ) )
Looking at the sources, it seems 'win32' should be
supported. But no; with the above example:
c:\>py -3
Hello list.
This little program should print the location of all
my installed Python packages:
-- 8< -- 8< ---
import pip
try:
packages = pip.get_installed_distributions (local_only=False, skip=())
except AttributeError:
import pkg_resources # Python3
packages =
dieter wrote:
directory with some possible leftovers. It there a connection
between this mysterious '-ip' package and this directory?
This is possible. A so called "distribution" can install
packages of a different name (for example, the distribution "Zope"
installs (among others) a package
Eryk Sun wrote:
The simplest way to create a shell link is via the Windows GUI shell,
Explorer. To inherit the working directory of the parent process,
leave the link's "start in" field empty. Also, add ".LNK" to the
system PATHEXT environment variable to allow finding link files
without having
Gisle Vanem added the comment:
I will add to this issue my *only* compile problem I had using clang-cl ver 9.
It has an issue with parsing the `frame_t` structure in Modules/_tracemalloc.c:
Modules/_tracemalloc.c(64,11): error: declaration of anonymous struct must be a
definition
typedef
Grant Edwards wrote:
On 2020-03-24, oliver wrote:
Use the win32com library to interact with Excel via COM.
Huh? I thought that the users have no way of running a local Python
app.
Maybe creating a self-contained .exe using PyInstaller?
For me, this:
pyinstaller.exe --noconfirm
New submission from Gisle Vanem :
Related to:
https://bugs.python.org/issue33351
where I commented above the following.
When using `clang-cl` to build, I get the following error:
```
Modules/_tracemalloc.c(55,9): error: declaration of anonymous struct must be a
definition
typedef struct
Has anybody noticed the speed of 'glob()' has
decreased somewhere between v3.6 and v3.10.
With this little test:
import os, sys, timeit, glob
# change to suite
globPath = u'e:/net/*/*/*/*'
def _glob():
glob.glob (globPath)
# I used this
Chris Angelico wrote:
Has anybody noticed the speed of 'glob()' has
decreased somewhere between v3.6 and v3.10.
I got these results:
Python 3.6.5:
1st run: 0.14694
2nd run: 0.09506 <- *always* the fastest
Python 3.7.7:<- from Nuget
1st run: 0.12440
2nd
Chris Angelico wrote:
BTW, I just noticed something. The path you're using for testing
purposes is "e:/net". Is that network-attached or local? If it's a
remote mount of some sort, then that will make a HUGE difference
No. Did the word 'net' make you think that :-) It's a local
FAT32
Barry Scott wrote:
If you have python from python.org installed you should be able to list all the
version you have installed
with the command:
py -0
When was that '-0' feature added?
I have Python 3.6 from Python.org and here a
'py.exe -0' gives:
Requested Python version (0) not
Ralf M. wrote:
I think the problem / misunderstanding is that Gisle put in py.ini only
[defaults]
python=3.6
and expected this to make py -3 start 3.6. However py -3 looks for a key named 'python3' and, not finding it, uses
default behaviour (ignoring the 'python' key), i.e. starts the
I have a question about the Python launcher;
c:\Windows\py.exe and the py.ini file.
I have both Python 3.6 (32-bit) and Python 3.8 (64-bit)
installed. And I have a 'c:\Users\Gisle\AppData\Local\py.ini'
with this only:
[defaults]
python=3.6
A copy of this is also in 'c:\Windows\py.ini'.
So
Barry Scott wrote:
A copy of this is also in 'c:\Windows\py.ini'.
So when I do a:
py -3 -c "import sys; print(sys.version)"
I would assume a "3.6..." would be printed.
But no, py.exe chooses to run my newest Python 3.8:
3.8.9 (default, Apr 13 2021, 15:54:59) [GCC 10.2.0 64 bit (AMD64)]
Edwards wrote:
I don't wish to run configure, I want to hand-construct
the makefile. PDOS is a very simple system, so I only
want to produce a single executable, no DLLs etc. I
don't need extensions to work or anything, all I need
to be able to do is run asma.
Why not try to port MicroPython
Loris Bennett wrote:
usage: grocli [-h] [-o {check,add,delete}] [-u USERS [USERS ...]] [-g GROUP]
Command line grouper tool
optional arguments:
-h, --helpshow this help message and exit
-o {check,add,delete}, --operation {check,add,delete}
hongy...@gmail.com wrote:
The following are some python TUI framework libraries/projects I have
discovered so far:
https://github.com/pfalcon/picotui
https://github.com/peterbrittain/asciimatics
https://github.com/bczsalba/pytermgui
https://github.com/GeorgeFilipkin/pulsemixer
Marco Sulla wrote:
Error LNK2001: unresolved external symbol PyErr_SetObject
and so on.
I post the part of my setup.py about the C Extension:
extra_compile_args = ["-DPY_SSIZE_T_CLEAN", "-DPy_BUILD_CORE"]
Shouldn't this be "-DPy_BUILD_CORE_MODULE"?
--
--gv
--
Shaozhong SHI wrote:
The following is used in a loop to get response code for each url.
print (urllib.request.urlopen(url).getcode())
However, error message says: URLError:
11001 == WSAHOST_NOT_FOUND.
Look in any 'winsock.h' header:
#define WSAHOST_NOT_FOUND (WSABASEERR+1001)
--
--gv
--
Abdur-Rahmaan Janhangeer wrote:
Thanks everybody for the answers. It was very enlightening. Here's my
solution:
# using rich console
def ensure_internet():
console = Console()
domains = [
'https://google.com',
'https://yahoo.com',
'https://bing.com',
'https://www.ecosia.org',
Abdur-Rahmaan Janhangeer wrote:
It's a demo to get the idea behind, uses requests and the rich library.
I'd never heard of 'Rich'. But d/l it and playing
with it, I came up with this version with fat green
spinner-bar:
import requests
from rich.console import Console
def ensure_internet():
Barry wrote:
Tip “py.exe -0” will list the state of installed pythons.
Not here; 'py.exe -0' gives:
Requested Python version (0) not installed
Which PyInstaller version support this '-0' option?
--
--gv
--
https://mail.python.org/mailman/listinfo/python-list
Greg Tibbet wrote:
> ellipse() uses the method self.draw.draw_ellipse() Okay, fine...
> but WHERE is draw_ellipse defined?? What magic is happening there?
> I've searched the entire PIL directory tree, and the ONLY two places
> draw_ellipse is mentioned are right there in the ellipse()
Greg Tibbet wrote:
> ellipse() uses the method self.draw.draw_ellipse() Okay, fine...
> but WHERE is draw_ellipse defined?? What magic is happening there?
> I've searched the entire PIL directory tree, and the ONLY two places
> draw_ellipse is mentioned are right there in the ellipse()
Michael Selik wrote:
> It suddenly occurred to me that if Microsoft announced it's
> Ubuntu-in-Windows feature today, no one would believe it.
My feeling too, but this was announced 30 March.
In the video in this link:
Thorsten Kampe wrote:
> My goal is to verify that other shells/interpreters on Windows work
> the same way as Python when running an application or creating a sub-
> process. Cmd does not. What's else there? I have Bash here but that's
> a Cygwin executable. And Cygwin Python does not work like
Hello list.
I'm moved my old Python27 installation from
f:\ProgramFiler\Python27 ( == 'ProgramFiles')
to
f:\gv\Python27
and now many 'scripts/*.exe' program fails
to start since the old path to 'Python.exe'
is wrong.
E.g. 'Scripts/pip2.exe' has the path
dn wrote:
E.g. 'Scripts/pip2.exe' has the path
"f:\programfiler\python27\python.exe" hard-coded
inside it.
Is there a easy way to fix this w/o re-installing this
old Python?
Yes, by putting a symbolic-link at the old 'programfiler' location which
points to the new 'gv' installation.
I'm
Eryk Sun wrote:
If the redirector app
is run without arguments, it will open the Microsoft Store to install
the latest version of the Python store app distribution. Currently
that means Python 3.10.
That is true with cmd. But with a shell like 4NT, I get:
c:\>
Hello list.
I have an issue with 'pip v. 22.3.1'. On any
'pip install' command I get warning like this:
c:\> pip3 install asciinema
WARNING: Ignoring invalid distribution -arkupsafe
(f:\gv\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -arkupsafe
Dieter Maurer wrote:
Otherwise no issues. But where is this text "-arkupsafe" stored
and how to get rid it it? I've searched through all of my .pth
files and found no such string.
Have you looked at the content of the folder mentioned
in the warnings (e.g. `...\site-packages`).
I had 2
Thomas Passin wrote:
So please, try to think out how your questions will seem to the reader, and be clear about what you are asking. You may
not know the terminology that some other people use, but don't let that stop you from being clear about what you really
need to find out. Including
I accidentally used 'argparse' like this in my Python 3.9 program:
parser.add_argument ("-c, --clean", dest="clean", action="store_true")
parser.add_argument ("-n, --dryrun", dest="dryrun", action="store_true")
instead of:
parser.add_argument ("-c", "--clean", dest="clean",
Thomas Passin wrote:
Are you trying to troll here?
You just showed how you got an error with this construction, so why are you
asking how to
get an error with this construction?
I meant (obviously), another error-message besides:
error: unrecognized arguments: -cn
Perhaps from
Dennis Lee Bieber wrote:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\Owner> Get-ChildItem -Path C:\Python310\ -Recurse -Name -Filter
"pip.*"
Tried it. Oh man what a slow process:
sync
86 matches
Mail list logo