Tag Archives: Python Learning Notes

python cx_Oracle.DatabaseError: Error while trying to retrieve text for error ORA-01804

Problem Description:

Using Python package CX_ When setting scheduled tasks on the Oracle server, errors are always reported, such as the title, but running alone is no problem

resolvent:

Under the guidance of the boss, add a few lines of code in front of the script to solve the problem perfectly. The environment variable path is configured according to its own path.

import os

os.environ["ORACLE_HOME"] = '/home/oracle/app/oracle/product/11.2.0/dbhome_1'
os.environ["ORACLE_BASE"] = '/home/oracle/app/oracle'
os.environ["ORACLE_SID"] = 'orcl'
os.environ["LD_LIBRARY_PATH"] = '/home/oracle/app/oracle/product/11.2.0/dbhome_1/lib:/lib:/usr/lib'

UserWarning: Failed to initialize NumPy: No module named ‘numpy.core._multiarray_umath‘

This error is usually caused by the mismatch of numpy versions, and the related MKL libraries are also uninstalled

pip unstall numpy
pip unstall mkl-service

Then PIP reinstall it

I just don’t know why I can’t solve it with CONDA uninstall + reinstall. Just replace it with PIP. It seems that there is a difference between uninstall and installed library?

Pre initialization of list content and length in Python

If you want to set the same initial value and desired length

>>> a=[None]*4
>>> print(a)
[None, None, None, None]

If we know the length of the list in advance, we can initialize the list of that length in advance, and then assign values to each list, which will be faster than each time list.append () more efficient.

If you want the sequence initial value, you can use the range function, but note that the range function returns an iterative object, which needs to be converted into a list

>>> b=list(range(10))
>>> print(b)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

>>> b=range(10)
>>> print(b)
range(0, 10)

If you want to eliminate unwanted data, you can use the list derivation

>>> c=[i for i in range(10) if i%2==0 and i<8]
>>> print(c)
[0, 2, 4, 6]

Life is short, You need Python~

When Python Django creates a database, can’t open file ‘ manage.py ‘: [Errno 2] No such file or directory

1. When creating a database after learning Diango new project, use the following command:

python manage.py migrate

‘can’t open file ‘manage.py’: [Errno 2] No such file or directory’ can’t open file ‘manage.py’: [Errno 2] No such file or directory ‘can’t open file ‘manage.py’: [Errno 2] No such file or directory’
Django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py: django-admin.py:

 django-admin.py startproject student_project .

4, then report the above described error, the reason: in fact, the path is wrong, did not set the soft connection. F:\python_stu\student_project\stu_env\Lib\site-packages\ Django \bin. Django-admin.py: F:\python_stu\student_project\stu_env\Lib\site-packages\ Django \bin.

python F:\python_stu\student_project\stu_env\Lib\site-packages\django\bin\django-admin.py startproject student_project

The above content is only for your reference, thank you!