Re: Problem in using libraries
On 4/3/23 10:43, Pranav Bhardwaj wrote: Why can't I able to use python libraries such as numpy, nudenet, playsound, pandas, etc in my python 3.11.2. It always through the error "import 'numpy' or any other libraries could not be resolved". Will restate what others have said in the hopes it might be even more clear that way. Python has an internal search path that it uses to find the module when you ask to "import". If a module is not found, that means it's not in the search path ("it's always a path problem"). You installed it, sure - but it went somewhere else. The search path is installation-specific (not just version-specific: for example if you have a system install of 3.10.x, and a virtualenv using the same 3.10.x, those will have different search paths). The search path can be amended or changed, but that's a different story. If you're going to install with pip, use the same Python you're going to do your work with. Don't trust that a command named "pip" maps to the same installation as that Python command. For that, either use an activated virtualenv, or do "name-of-my-python -m pip install". You can always check your work by doing "name-of-my-python -m pip list" - what does that particular installation see as installed? Or - if you're using the classic set of "scientific" packages like numpy and pandas, you might look at installing it all using conda instead of pip: it to a large extent exists to help with getting those very common bundles of things set up without going through the wrestling match you're going though. -- https://mail.python.org/mailman/listinfo/python-list
Python's Plugins for NetBeans 16
Dear Python Support, I'm looking for "Python Plugins for NetBeans 16". I already installed Python 3.11.2 for Windows 11 and I can't find such plugins to create python projects. I would appreciate it if you tell me where to download these plugins or if there is any other issue that I should do differently. Thank you very much in advance. Best to all. Carlos Fulqueris +54 911 2251 9302 -- https://mail.python.org/mailman/listinfo/python-list
Re: Windows installer from python source code without access to source code
> On 4 Apr 2023, at 16:28, Jim Schwartz wrote: > > Where can I download that cl program? I've used gcc before, but I hear that > cl can use a setup.py program to run the compile and link and create a > windows .msi installer. Is that true? It is part of visual studio C++. Once you have that installed there are bat files that setup environment in the terminal. Then you can use cl, nmake etc Barry > > -Original Message- > From: Eryk Sun > Sent: Friday, March 31, 2023 12:55 PM > To: Jim Schwartz > Cc: python-list@python.org > Subject: Re: Windows installer from python source code without access to > source code > >> On 3/31/23, Jim Schwartz wrote: >> I want a windows installer to install my application that's written in >> python, but I don't want the end user to have access to my source code. > > Cython can compile a script to C source code for a module or executable > (--embed). The source can be compiled and linked normally. > For example, the following builds a "hello.exe" executable based on a > "hello.py" script. > >> cython -3 --embed hello.py >> set "PYI=C:\Program Files\Python311\include" >> set "PYL=C:\Program Files\Python311\libs" >> cl /I"%PYI%" hello.c /link /libpath:"%PYL%" >> copy hello.exe embed >> embed\hello.exe >Hello, World! > > I extracted the complete embeddable distribution of Python 3.11 into the > "embed" directory. You can reduce the size of the installation, if needed, by > minimizing the zipped standard library and removing pyd extensions and DLLs > that your application doesn't use. > > The generated "hello.c" is large and not particularly easy to read, but here > are some snippets [...]: > >[...] >/* Implementation of 'hello' */ >static PyObject *__pyx_builtin_print; >static const char __pyx_k_main[] = "__main__"; >static const char __pyx_k_name[] = "__name__"; >static const char __pyx_k_test[] = "__test__"; >static const char __pyx_k_print[] = "print"; >static const char __pyx_k_Hello_World[] = "Hello, World!"; >[...] > /* "hello.py":1 > * print("Hello, World!") # << > */ > __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Hello_World); >if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 1, __pyx_L1_error) >[...] > /* "hello.py":1 > * print("Hello, World!") # << > */ > __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple_, > NULL); >if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) >[...] >int wmain(int argc, wchar_t **argv) { >[...] >if (argc && argv) >Py_SetProgramName(argv[0]); >Py_Initialize(); >if (argc && argv) >PySys_SetArgv(argc, argv); >[...] > m = PyInit_hello(); >[...] >if (Py_FinalizeEx() < 0) >return 2; >[...] >return 0; >[...] > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Problem in using libraries
Pranav Bhardwaj wrote at 2023-4-3 22:13 +0530: >Why can't I able to use python libraries such as numpy, nudenet, playsound, >pandas, etc in my python 3.11.2. It always through the error "import >'numpy' or any other libraries could not be resolved". The "libraries" you speak of are extensions (i.e. not part of the Python download). Extensions are Python minor version specific. You must install them for each Python minor version. E.g. you can use an extension installation for Python 3.10 for any Python 3.10.x, but you must install it again for Python 3.11. -- https://mail.python.org/mailman/listinfo/python-list
Re: When is logging.getLogger(__name__) needed?
Peter Otten <__pete...@web.de> writes: > On 31/03/2023 15:01, Loris Bennett wrote: [snip (53 lines)] > Your problem has nothing to do with logging -- it's about visibility > ("scope") of names: > def use_name(): > print(name) > > def define_name(): > name = "Loris" > > use_name() > Traceback (most recent call last): > File "", line 1, in > use_name() > File "", line 2, in use_name > print(name) > NameError: name 'name' is not defined > > Binding (=assigning to) a name inside a function makes it local to that > function. If you want a global (module-level) name you have to say so: > def define_name(): > global name > name = "Peter" > > define_name() use_name() > Peter Thanks for the example and reminding me about Python's scopes. With global name def use_name(): print(name) def define_name(): name = "Peter" define_name() use_name() I was initially surprised by the following error: ~/tmp $ python3 global.py Traceback (most recent call last): File "/home/loris/tmp/global.py", line 10, in use_name() File "/home/loris/tmp/global.py", line 4, in use_name print(name) NameError: name 'name' is not defined but I was misinterpreting global name to mean define a global variable 'name' whereas it actually seems to mean more like use the global variable 'name' Correct? -- This signature is currently under constuction. -- https://mail.python.org/mailman/listinfo/python-list
RE: Windows installer from python source code without access to source code
Where can I download that cl program? I've used gcc before, but I hear that cl can use a setup.py program to run the compile and link and create a windows .msi installer. Is that true? -Original Message- From: Eryk Sun Sent: Friday, March 31, 2023 12:55 PM To: Jim Schwartz Cc: python-list@python.org Subject: Re: Windows installer from python source code without access to source code On 3/31/23, Jim Schwartz wrote: > I want a windows installer to install my application that's written in > python, but I don't want the end user to have access to my source code. Cython can compile a script to C source code for a module or executable (--embed). The source can be compiled and linked normally. For example, the following builds a "hello.exe" executable based on a "hello.py" script. > cython -3 --embed hello.py > set "PYI=C:\Program Files\Python311\include" > set "PYL=C:\Program Files\Python311\libs" > cl /I"%PYI%" hello.c /link /libpath:"%PYL%" > copy hello.exe embed > embed\hello.exe Hello, World! I extracted the complete embeddable distribution of Python 3.11 into the "embed" directory. You can reduce the size of the installation, if needed, by minimizing the zipped standard library and removing pyd extensions and DLLs that your application doesn't use. The generated "hello.c" is large and not particularly easy to read, but here are some snippets [...]: [...] /* Implementation of 'hello' */ static PyObject *__pyx_builtin_print; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_print[] = "print"; static const char __pyx_k_Hello_World[] = "Hello, World!"; [...] /* "hello.py":1 * print("Hello, World!") # << */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Hello_World); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 1, __pyx_L1_error) [...] /* "hello.py":1 * print("Hello, World!") # << */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) [...] int wmain(int argc, wchar_t **argv) { [...] if (argc && argv) Py_SetProgramName(argv[0]); Py_Initialize(); if (argc && argv) PySys_SetArgv(argc, argv); [...] m = PyInit_hello(); [...] if (Py_FinalizeEx() < 0) return 2; [...] return 0; [...] -- https://mail.python.org/mailman/listinfo/python-list
Re: Python not showing correct version
So I disabled the manage app execution for python 3.10, created the py.ini file and executed setx.exe PY_PYTHON 3.8,setx.exe PY_PYTHON3 3.8. After that i uninstalled 3.8 and reinstalled and now the version is showing correctly. Thanks everyone for the help. Thanks Sumeet On Sat, 1 Apr 2023 at 20:40, Eryk Sun wrote: > On 4/1/23, Barry Scott wrote: > > > > I find user environment on windows to be less flexible to work with then > > adding a py.ini. On my Windows 11 I added > > %userprofile%\AppData\Local\py.ini. > > To make python 3.8 the default that py.exe uses put this in py.ini: > > > > [defaults] > > python=3.8-64 > > python3=3.8-64 > > Using "py.ini" has the advantage that launcher always reads the file. > The value of the environment variables, on the other hand, may be > stale. If you keep a lot of shells running, it would be tedious to > have to manually update the PY_PYTHON* variables in each shell. That > said, it should be rare that one needs to change the persisted default > versions. For temporary changes, the PY_PYTHON* environment variables > are more flexible and take precedence over "py.ini". > > If one doesn't use "py.ini" to set the defaults, it's easy to modify > the persisted user environment using "setx.exe"[^1]. For example: > > setx.exe PY_PYTHON 3.8 > setx.exe PY_PYTHON3 3.8 > > setx.exe broadcasts a WM_SETTINGCHANGE "Environment" window message, > which causes Explorer to update its environment. Thus any program run > from Explorer will see the new values. A program launched in a new tab > in Windows Terminal also gets a fresh environment. However, existing > CLI shells (CMD, PowerShell, bash), and programs started by them, will > still have the old environment values. The latter is where using > "py.ini" to set the defaults has the advantage. > > --- > > [^1]: Note that "setx.exe" should never be used to set the persisted > user or machine "Path" value to the current %PATH%. When loading the > environment, the user "Path" gets appended to the machine "Path". > Setting the entire expanded and concatenated value to one or the other > leads to a bloated, redundant PATH value, and it also loses the > flexible configuration based on REG_EXPAND_SZ values. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: [Python-Dev] Small lament...
On 4/04/23 2:09 pm, avi.e.gr...@gmail.com wrote: Sadly, between Daylight Savings time and a newer irrational PI π Day, I am afraid some April Foolers got thrown off albeit some may shower us with nonsense in May I. Pi day isn't responsible, but it is because of changes to daylight saving. The International Bureau of Weights and Measures announced that, in order to gain a few more days of summer weather, all clocks would be put back by 96 hours at midnight on 31 March 2023. So April 1 is now occurring on what would have been April 4. Expect the usual torrent of silliness to arrive shortly. -- Greg -- https://mail.python.org/mailman/listinfo/python-list