Python Forum
Problem with flask on Mac - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Problem with flask on Mac (/thread-41311.html)

Pages: 1 2


RE: Problem with flask on Mac - David763 - Dec-19-2023

(Dec-19-2023, 04:28 PM)snippsat Wrote: Now you are using Anaconda3 then most a environment be activated,(base) is the default one.
Are a environment activated?
It's best is to make new environment and not use (base) for this.
As you see here it goes over to a other version of Python that's not Anaconda.
/private/var/folders/rv/n6zb4_qs6ql1r8cc2gs7w8_w0000gn/T/pip-build-env-nqoa4iyp/overlay/lib/python3.11/s
This should of course not happen as you install to Anaconda,see the Path to Python 3.11 is different.
/Users/amirhosein/anaconda3/lib/python3.11/site-packages/pip
Example is i use Miniconda(work the same as Anaconda) and then first active a environment then it works.
G:\div_code
λ G:\miniconda3\Scripts\activate.bat tom_env

# When a environment it has (name_of_env) 
G:\div_code
(tom_env) λ pip install flask-mysqldb
Collecting flask-mysqldb
  Downloading Flask_MySQLdb-2.0.0-py3-none-any.whl (4.9 kB)
Collecting Flask>=1.0.4
  Using cached flask-3.0.0-py3-none-any.whl (99 kB)
Collecting mysqlclient>=2.2.0
  Downloading mysqlclient-2.2.1-cp310-cp310-win_amd64.whl (202 kB)
     |████████████████████████████████| 202 kB 731 kB/s
Collecting Jinja2>=3.1.2
  Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
Collecting itsdangerous>=2.1.2
  Using cached itsdangerous-2.1.2-py3-none-any.whl (15 kB)
Collecting click>=8.1.3
  Downloading click-8.1.7-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 3.3 MB/s
Collecting blinker>=1.6.2
  Downloading blinker-1.7.0-py3-none-any.whl (13 kB)
Collecting Werkzeug>=3.0.0
  Downloading werkzeug-3.0.1-py3-none-any.whl (226 kB)
     |████████████████████████████████| 226 kB 6.4 MB/s
Requirement already satisfied: colorama in g:\miniconda3\envs\tom_env\lib\site-packages (from click>=8.1.3->Flask>=1.0.4->flask-mysqldb) (0.4.4)
Requirement already satisfied: MarkupSafe>=2.0 in g:\miniconda3\envs\tom_env\lib\site-packages (from Jinja2>=3.1.2->Flask>=1.0.4->flask-mysqldb) (2.0.1)
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.1.3-cp310-cp310-win_amd64.whl (17 kB)
Installing collected packages: MarkupSafe, Werkzeug, Jinja2, itsdangerous, click, blinker, mysqlclient, Flask, flask-mysqldb
  Attempting uninstall: MarkupSafe
    Found existing installation: MarkupSafe 2.0.1
    Uninstalling MarkupSafe-2.0.1:
      Successfully uninstalled MarkupSafe-2.0.1
  Attempting uninstall: Jinja2
    Found existing installation: Jinja2 3.0.3
    Uninstalling Jinja2-3.0.3:
      Successfully uninstalled Jinja2-3.0.3
Successfully installed Flask-3.0.0 Jinja2-3.1.2 MarkupSafe-2.1.3 Werkzeug-3.0.1 blinker-1.7.0 click-8.1.7 flask-mysqldb-2.0.0 itsdangerous-2.1.2 mysqlclient-2.2.1

# Test
G:\div_code
(tom_env) λ python
Python 3.10.1 | packaged by conda-forge | (main, Dec 22 2021, 01:34:40) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from flask_mysqldb import MySQL
>>> # No error
>>> exit()

How do I make a new environment ?


RE: Problem with flask on Mac - David763 - Dec-19-2023

(Dec-19-2023, 04:16 PM)menator01 Wrote: You may be better off installing pymysql and using that. I'm on ubuntu linux and get the same install problem.

Thanks for the suggestion


RE: Problem with flask on Mac - snippsat - Dec-19-2023

(Dec-19-2023, 05:00 PM)David763 Wrote: How do I make a new environment ?
Creating an environment with commands

Example for this task install new Python3.11 version with pip,can also add Spyder if need a editor.
Conda-forge for repeatable way on Windows, Linux and OSX.
conda create --name my_env -c conda-forge flask spyder python=3.11.5
Then activate environment and can install pip install flask-mysqldb.
See that when environment is activated and test pip it will point to the Python in Anaconda folder and not the OS Python version path.
G:\div_code
(tom_env) λ pip -V
pip 21.3.1 from G:\miniconda3\envs\tom_env\lib\site-packages\pip (python 3.10)



RE: Problem with flask on Mac - David763 - Dec-19-2023

(Dec-19-2023, 05:31 PM)snippsat Wrote:
(Dec-19-2023, 05:00 PM)David763 Wrote: How do I make a new environment ?
Creating an environment with commands

Example for this task install new Python3.11 version with pip,can also add Spyder if need a editor.
Conda-forge for repeatable way on Windows, Linux and OSX.
conda create --name my_env -c conda-forge flask spyder python=3.11.5
Then activate environment and can install pip install flask-mysqldb.
See that when environment is activated and test pip it will point to the Python in Anaconda folder and not the OS Python version path.
G:\div_code
(tom_env) λ pip -V
pip 21.3.1 from G:\miniconda3\envs\tom_env\lib\site-packages\pip (python 3.10)

Still getting the same error…