Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Using MySQL but noticed that your Python scripts no longer able to retrieve data as usual?

If the following symptoms apply to you:

  • You recently migrated from Azure MariaDB to Azure MySQL.
  • MySQL Workbench is able to return data successfully.
  • You have not made any changes to your Python scripts, but they are no longer able to retrieve data as they did before the migration.

What you should do?
  • Please check if you are using mysql-connector as your library. If yes, please uninstall it by using this command:
    • pip uninstall mysql-connector -y
  • After that, please run this command to install the correct MySQL library for Python:
    • pip install mysql-connector-python

Some useful reference articles related to this issue:

Hit "Authentication plugin 'caching_sha2_password' is not supported" when you are using mysql-connector with Python?

 Hit "Authentication plugin 'caching_sha2_password' is not supported" when you are using mysql-connector with Python?


Well, the answer is:

a). Uninstall mysql-connector, and

pip uninstall mysql-connector

b). Proceed to install mysql-connector-python

pip install mysql-connector-python


Enjoy scripting!

fatal error C1083: Cannot open include file: 'sqlfront.h': No such file or directory

If your environment is something like below:
  • Windows operating system, either 10 or 11
  • Python 3.13
You are trying to install pymssql, and

You hit this error message: fatal error C1083: Cannot open include file: 'sqlfront.h': No such file or directory


The quick answer for this issue is:
  • Downgrade your Python to version 3.12. You can easily get it from Microsoft Store.
  • After that, run this command to install pymssql as usual: pip install pymssql

Note: Please don't waste your time for that freetds thingy.. it won't work. A lot of links shared via stackoverflow forums already being removed or outdated.

10 steps to setup your Python Luno trading bots on Microsoft Azure

10 steps to setup your Python Luno trading bots on Microsoft Azure.

Step 1: Create a Virtual Machine for Ubuntu with size = B1s. You may choose the cheapest region, which is East US 2 - refer https://azureprice.net/You do not need any graphical user interface for this Ubuntu.


Step 2: Now, configure the SSH to only allows the public IP address from your computer.

Step 3: Log into that Virtual Machine to remove Python 2.7 and upgrade it to version 3.10 - refer https://www.itsupportwale.com/blog/how-to-upgrade-to-python-3-10-on-ubuntu-18-04-and-20-04-lts/. Remember to install pip too.

Step 4: Now, install MySQL on your Virtual Machine using sudo command - refer https://linuxize.com/post/how-to-install-mysql-on-ubuntu-18-04/.

Step 5: After that, install MySQL Client, MySQL Connector and Luno Python SDK on Python 3.10 inside your Virtual Machine. You might need setuptools as pre-requisites.

Step 6. Deploy the Python scripts for your bots.

Step 7. Check the configurations file.

Step 8. Build the database for your bots, which will be used to store trading information.

Step 9. Use nohup command to execute your Python bots at background.

Step 10. Use ps aux command to check whether your Step 9 has been done correctly or not.

Thanks.

"Character set 'utf8' unsupported" when you run Python script with MySQL database?

When you run Python script with MySQL database, system gives you this error message:

Character set 'utf8' unsupported


What Do You Need To Do?

pip uninstall mysql-connector-python

Unable to find resource t64.exe in package pip._vendor.distlib

 Hitting this error message "Unable to find resource t64.exe in package pip._vendor.distlib" when trying to upgrade your PIP to latest version?


Try to run the commands below:

  • python -m pip uninstall pip setuptools
  • pip install --upgrade setuptools


Source: https://www.cnblogs.com/poloyy/p/12966270.html

How to open an URL in Chrome incognito mode using Python?

You may refer to the sample codes below from us. We use Windows platform as an example:


import webbrowser

def main():
    fUrl: str = 'https://prgexp.blogspot.com/'

    chrome_path = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
    webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chrome_path))
    webbrowser.get('chrome').args.append('--incognito')
    webbrowser.get('chrome').open_new_tab(fUrl)

if __name__ == '__main__':
    main()

"The wheel package is not available" when you try to install matplotlib in Python

 Hit into "The wheel package is not available" when you try to install matplotlib in Python?

python -m pip install matplotlib


Think you should try to run the following command first:

pip install wheel