MPEDS / mpeds-coder

MPEDS Annotation Interface
MIT License
18 stars 5 forks source link

AttributeError: module 'config' has no attribute 'MYSQL_USER' #79

Open yucluo opened 5 months ago

yucluo commented 5 months ago

When I run python setup.py as instructed I get this error:

(base) Yuchens-Air-3:mpeds-coder yuchenluo$ python setup.py Traceback (most recent call last): File "/Users/yuchenluo/Desktop/mpeds-coder/setup.py", line 1, in from database import db_session, init_db File "/Users/yuchenluo/Desktop/mpeds-coder/database.py", line 7, in (config.MYSQL_USER, config.MYSQL_PASS, config.MYSQL_DB, config.MYSQL_SOCK, 'utf8'), AttributeError: module 'config' has no attribute 'MYSQL_USER'

alexhanna commented 5 months ago

You need to make a copy of config.py-example and rename it to config.py, then change the credentials for your MySQL database.

yucluo commented 5 months ago

Thanks! That was super helpful! I am fairly new to MySQL database. When I tried running the code again, it gave me this error

(base) Yuchens-Air-3:mpeds-coder yuchenluo$ python setup.py

Traceback (most recent call last):

File "/Users/yuchenluo/Desktop/mpeds-coder/setup.py", line 1, in

from database import db_session, init_db

File "/Users/yuchenluo/Desktop/mpeds-coder/database.py", line 6, in

mysql_engine = ***@***.***/%s?unix_socket=%s&charset=%s' % File "", line 2, in create_engine File "/Users/yuchenluo/anaconda3/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 309, in warned return fn(*args, **kwargs) File "/Users/yuchenluo/anaconda3/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 560, in create_engine dbapi = dialect_cls.dbapi(**dbapi_args) File "/Users/yuchenluo/anaconda3/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 163, in dbapi return __import__("MySQLdb") ModuleNotFoundError: No module named 'MySQLdb' I tried pip install MySQLdb without success... If you can help take a look at it it would be great. Thanks! On Wed, May 29, 2024 at 3:36 PM Alex Hanna ***@***.***> wrote: > You need to make a copy of config.py-example and rename it to config.py, > then change the credentials for your MySQL database. > > — > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> > -- Yuchen Luo (罗予晨) Ph.D. Student, NYU Department of Sociology
alexhanna commented 5 months ago

I think you need to pip install mysql-python

yucluo commented 5 months ago

Thanks for the reply. I have been trying to get mysql-python installed with no luck. I also tried upgrading wheel which didn't work. If you can help take a look at it that would be great!

(base) Yuchens-Air-3:mpeds-coder yuchenluo$ pip install mysql-python

Collecting mysql-python

Using cached MySQL-python-1.2.5.zip (108 kB)

Preparing metadata (setup.py) ... error

error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.

│ exit code: 1

╰─> [8 lines of output]

  Traceback (most recent call last):

    File "<string>", line 2, in <module>

    File "<pip-setuptools-caller>", line 34, in <module>

    File

"/private/var/folders/qx/bjrwt3jn45n4lc5s74y_0l7c0000gn/T/pip-install-6ve6fe8u/mysql-python_8288f2ba9ee7492b9b6f2eb2d023f995/setup.py", line 13, in

      from setup_posix import get_config

    File

"/private/var/folders/qx/bjrwt3jn45n4lc5s74y_0l7c0000gn/T/pip-install-6ve6fe8u/mysql-python_8288f2ba9ee7492b9b6f2eb2d023f995/setup_posix.py", line 2, in

      from ConfigParser import SafeConfigParser

  ModuleNotFoundError: No module named 'ConfigParser'

  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

error: metadata-generation-failed

× Encountered error while generating package metadata.

╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.

hint: See above for details.

On Thu, May 30, 2024 at 1:22 PM Alex Hanna @.***> wrote:

I think you need to pip install mysql-python

— Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_MPEDS_mpeds-2Dcoder_issues_79-23issuecomment-2D2140358829&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=upPZc3sE3d6lKrBI-4xh3w&m=wmhrL5LZLjjOfFvnDeCorpTSgf-92itwR63L6Loyru1a_MVz-L2reJHX3xExVDnY&s=LcjUiL_HRQ0qNAxuUy-e1S_7t4caNG0PpCfK208IqNs&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_APVT6G4ZSY3KX65G7FOETI3ZE5N47AVCNFSM6AAAAABIPSD5YSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBQGM2TQOBSHE&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=upPZc3sE3d6lKrBI-4xh3w&m=wmhrL5LZLjjOfFvnDeCorpTSgf-92itwR63L6Loyru1a_MVz-L2reJHX3xExVDnY&s=Pjr7UDr2DEMfrGN3GYXylDtwX7O3WulmIbBuxt4IfBg&e= . You are receiving this because you authored the thread.Message ID: @.***>

-- Yuchen Luo (罗予晨) Ph.D. Student, NYU Department of Sociology

yucluo commented 5 months ago

After some browsing the internet seems to say that MySQL-python does not currently support Python 3 which is probably why I can't get this working on my machine...

https://stackoverflow.com/questions/14087598/python-3-importerror-no-module-named-configparser

On Mon, Jun 3, 2024 at 11:56 AM Yuchen Luo @.***> wrote:

Thanks for the reply. I have been trying to get mysql-python installed with no luck. I also tried upgrading wheel which didn't work. If you can help take a look at it that would be great!

(base) Yuchens-Air-3:mpeds-coder yuchenluo$ pip install mysql-python

Collecting mysql-python

Using cached MySQL-python-1.2.5.zip (108 kB)

Preparing metadata (setup.py) ... error

error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.

│ exit code: 1

╰─> [8 lines of output]

  Traceback (most recent call last):

    File "<string>", line 2, in <module>

    File "<pip-setuptools-caller>", line 34, in <module>

    File

"/private/var/folders/qx/bjrwt3jn45n4lc5s74y_0l7c0000gn/T/pip-install-6ve6fe8u/mysql-python_8288f2ba9ee7492b9b6f2eb2d023f995/setup.py", line 13, in

      from setup_posix import get_config

    File

"/private/var/folders/qx/bjrwt3jn45n4lc5s74y_0l7c0000gn/T/pip-install-6ve6fe8u/mysql-python_8288f2ba9ee7492b9b6f2eb2d023f995/setup_posix.py", line 2, in

      from ConfigParser import SafeConfigParser

  ModuleNotFoundError: No module named 'ConfigParser'

  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

error: metadata-generation-failed

× Encountered error while generating package metadata.

╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.

hint: See above for details.

On Thu, May 30, 2024 at 1:22 PM Alex Hanna @.***> wrote:

I think you need to pip install mysql-python

— Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_MPEDS_mpeds-2Dcoder_issues_79-23issuecomment-2D2140358829&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=upPZc3sE3d6lKrBI-4xh3w&m=wmhrL5LZLjjOfFvnDeCorpTSgf-92itwR63L6Loyru1a_MVz-L2reJHX3xExVDnY&s=LcjUiL_HRQ0qNAxuUy-e1S_7t4caNG0PpCfK208IqNs&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_APVT6G4ZSY3KX65G7FOETI3ZE5N47AVCNFSM6AAAAABIPSD5YSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBQGM2TQOBSHE&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=upPZc3sE3d6lKrBI-4xh3w&m=wmhrL5LZLjjOfFvnDeCorpTSgf-92itwR63L6Loyru1a_MVz-L2reJHX3xExVDnY&s=Pjr7UDr2DEMfrGN3GYXylDtwX7O3WulmIbBuxt4IfBg&e= . You are receiving this because you authored the thread.Message ID: @.***>

-- Yuchen Luo (罗予晨) Ph.D. Student, NYU Department of Sociology

-- Yuchen Luo (罗予晨) Ph.D. Student, NYU Department of Sociology

alexhanna commented 5 months ago

Ah, there's your problem. This will only run on Python 2. So you'll have to install Python 2 in a separate location on your machine.