Colab from google is a great tool when you want to write equations. I show a simple example with LaTeX formula with this colab notebook named catafest_034.
Is a blog about python programming language. You can see my work with python programming language, tutorials and news.
Tuesday, January 24, 2023
Python : Fix DLL load failed while importing ...
This error DLL load failed while importing ... can have many causes like conflicts with the already installed packages, and also it can break your current environment.
>>> import PyQt6
>>> from PyQt6.QtCore import QUrl
Traceback (most recent call last):
...
ImportError: DLL load failed while importing QtCore: The specified module could not be found.You can see I used to reinstall the PyQt6 python package with this argument --ignore-installed:
pip3 install PyQt6 --user --ignore-installed
Collecting PyQt6
...
Installing collected packages: PyQt6-Qt6, PyQt6-sip, PyQt6
WARNING: The scripts pylupdate6.exe and pyuic6.exe are installed in
...
which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed PyQt6-6.4.0 PyQt6-Qt6-6.4.2 PyQt6-sip-13.4.0
The --ignore-installed option for the pip package manager was first introduced in version 6.0, which was released in April 2014.
The old install give me this error and when I try to use I got this:
>>> from PyQt6 import *
>>> dir(PyQt6)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']Now after I reinstall with this option the result is good:
>>> import PyQt6
>>> from PyQt6 import QtCore
>>> dir(PyQt6)
['QtCore', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'sip']
>>> from PyQt6.QtCore import QUrl
Posted by
Cătălin George Feștilă
Labels:
2023,
error,
module,
modules,
packages,
pip,
pip3,
PyQt6,
python,
python 3,
python modules,
python packages,
tutorial,
tutorials
Python 3.11.0 : The openai python package - part 001.
The OpenAI Python library provides convenient access to the OpenAI API from applications written in the Python language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the OpenAI API.
You can see more about this on the GitHub project.
in order to use this package you need to have a A.P.I. key for OpenAI beta features from this website.
Create a key and copy into file or clipboard beacuse this cannot be accesed after you created.
Use the pip tool to install the openai package:
pip3 install openai --userI tested with a default example and a simple question: What is the python programmin language?
import os
import openai
openai.api_key = "your_API_OpenAI_key"
response = openai.Completion.create(
model="text-davinci-003",
prompt="What is the python programmin language?",
temperature=0.7,
max_tokens=100,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
print(response)I run this python script code and the result is this:
python openai001.py
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"text": "\n\nPython is a high-level, interpreted, general-purpose programming language.
It was created by Guido van Rossum and first released in 1991. Python has a wide variety of
uses and is a popular language for data science, web development, automation, and artificial
intelligence. It is also a popular language for scripting and general-purpose programming."
}
],
"created": 1674588982,
"id": "cmpl-6cJNeACMtayBlExV1GJpilde0KcBN",
"model": "text-davinci-003",
"object": "text_completion",
"usage": {
"completion_tokens": 71,
"prompt_tokens": 8,
"total_tokens": 79
}
}
Posted by
Cătălin George Feștilă
Labels:
2023,
module,
modules,
OpenAI,
packages,
python,
python 3,
python modules,
python packages,
tutorial,
tutorials
Monday, January 23, 2023
Python 3.11.0 : About py launcher tool for Windows.
The py launcher tool for Windows is included in the Python for Windows installer starting from version 3.3.
This command-line tool allows you to easily configure and switch between multiple versions of Python installed on a Windows system.
This tool allows you to easily switch between different versions of Python without modifying the system's PATH environment variable, and it also allows you to set default versions of Python for different file extensions.
Let's see some examples
This will argument will give you the current version of your python command:
py --version
Python 3.11.0This will enumerate all your python versions from Windows O.S.:
py -0
-V:3.11 * Python 3.11 (64-bit)
-V:3.10 Python 3.10 (64-bit)
-V:3.9 Python 3.9 (64-bit)
-V:3.7 Python 3.7 (64-bit)This will set the python command to a specific version in this case 3.10 :
>py -3.10
Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()This will run a python script named scripting001.py with a specific version of python:
py -3.10 scripting001.py
Posted by
Cătălin George Feștilă
Labels:
2023,
module,
modules,
packages,
py,
python,
python 3,
python modules,
python packages,
tool,
tutorial,
tutorials
Thursday, January 19, 2023
Python 3.11.0 : The parfive python package.
Today I tested this simple parfive 2.0.2 version python package with the default example from the official website.
A parallel file downloader using asyncio. parfive can handle downloading multiple files in parallel as well as downloading each file in a number of chunks.
The default example works great but when I try to get direct movie files from free web this not work.
Parfive is a lightweight library, I try to download large files but give me error 206.
Posted by
Cătălin George Feștilă
Labels:
2023,
module,
modules,
packages,
partfive,
python,
python 3,
python modules,
python packages,
tutorial,
tutorials
Thursday, January 12, 2023
Python 3.11.0 : The numpy-quaternion python package - part 001.
I write an article on my website about artificial intelligence and I used python to show a simple example with quaternions.
This Python module adds a quaternion dtype to NumPy and you can read about this on the official website.
I may have mistakenly installed a python packet with a similar name and I had to install it with the command:
python -m pip uninstall quaternionthe next step was to install this command
python -m pip install --upgrade --no-deps --force-reinstall numpy-quaternionThe source code I used defines two quaternions, one with real part a and imaginary parts, and one quaternion using Euler angles.
Then is perform the rotation uses quaternion multiplication.
Let's see the source code
import numpy as np
import quaternion
# define a quaternion with real part a and imaginary parts bi, cj, dk
a = 1
b = 2
c = 3
d = 4
q = np.quaternion(a, b, c, d)
# define a quaternion using euler angles
x = 1.0
y = 2.0
z = 3.0
q2 = quaternion.from_euler_angles(x, y, z)
# define a vector to rotate
v = [1, 0, 0]
# perform the rotation using quaternion multiplication
# quaternion multiplication is not commutative, the order matters
# because this line of source code will not work: rotated_v = q2 * v * q2.conj()
rotated_v = (q2 * quaternion.quaternion(0, *v)) * q2.conj()
print(rotated_v)This is the result:
quaternion(0, 0.103846565151668, 0.422918571742548, 0.900197629735517)
Posted by
Cătălin George Feștilă
Labels:
2023,
module,
modules,
numpy,
numpy-quaternion,
OpenAI,
packages,
python,
python 3,
python modules,
python packages,
tutorial,
tutorials
Subscribe to:
Comments (Atom)