I created a virtualenv with following installed:
$ pip freeze
aniso8601==9.0.1
attrs==22.2.0
click==8.1.3
configparser==5.3.0
Flask==2.2.2
flask-restplus==0.13.0
Flask-SQLAlchemy==3.0.2
greenlet==2.0.1
itsdangerous==2.1.2
Jinja2==3.1.2
jsonschema==4.17.3
MarkupSafe==2.1.1
mysql-connector-python==8.0.31
protobuf==3.20.1
PyMySQL==1.0.2
pyrsistent==0.19.2
pytz==2022.7
six==1.16.0
SQLAlchemy==1.4.45
Werkzeug==2.2.2
You can see I have PyMySQL and mysql-connector-python installed but still I am getting this error:
Traceback (most recent call last):
File "/home/ciasto/Dev/crud_app/src/start.py", line 1, in <module>
from todo_app.extensions import db
File "/home/ciasto/Dev/crud_app/src/todo_app/extensions.py", line 5, in <module>
db = SQLAlchemy(app)
File "/home/ciasto/Dev/crud_app/crud_app_env/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 219, in __init__
self.init_app(app)
File "/home/ciasto/Dev/crud_app/crud_app_env/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 320, in init_app
engines[key] = self._make_engine(key, options, app)
File "/home/ciasto/Dev/crud_app/crud_app_env/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 606, in _make_engine
return sa.engine_from_config(options, prefix="")
File "/home/ciasto/Dev/crud_app/crud_app_env/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 743, in engine_from_config
return create_engine(url, **options)
File "<string>", line 2, in create_engine
File "/home/ciasto/Dev/crud_app/crud_app_env/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 309, in warned
return fn(*args, **kwargs)
File "/home/ciasto/Dev/crud_app/crud_app_env/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 548, in create_engine
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/home/ciasto/Dev/crud_app/crud_app_env/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 163, in dbapi
return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'
I have tried reinstalling
pip install MySQL-python
pip install ConfigParser
pip install MySQLdb
I have tried the solutions from the ModuleNotFoundError: No module named 'MySQLdb'
but it didn't worked for me.
I am using ubuntu jammy on x86 platform.
I was able to fix this issue by first installing
apt install libmysqlclient-dev
then pip install mysqlclient
Related
also tried installing psycopg2-binary as well but same error (not sure what am I missing here, new to PostgreSQL and PyCharm)
pip install psycopg2
pip install psycopg2-binary
Error message
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==7.1.0', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2365, in resolve
raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'main'
first of all run easy_install --upgrade pip command to upgrade your pip.
then type and run this
from pip._internal import main
main(['install', 'psycopg2'])
After that run this
main(['install', 'psycopg2-binary'])
Thanks for reading.
I do need your help.
I wanted to install google-cloud-speech, so I typed
'pip install google-cloud-speech'
in cmd.exe(Windows 10)
but error occured.
Is there any proper way to solve this, please let me know it.
Thanks.
Collecting google-cloud-speech
Using cached google_cloud_speech-0.32.0-py2.py3-none-any.whl
Collecting requests<3.0dev,>=2.18.4 (from google-cloud-speech)
Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting googleapis-common-protos[grpc]<2.0dev,>=1.5.2 (from google-cloud-speech)
Using cached googleapis-common-protos-1.5.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\developer\appdata\local\programs\python\python36-32\lib\site-packages\setuptools\__init__.py", line 10, in <module>
from setuptools.extern.six.moves import filter, filterfalse, map
File "c:\users\developer\appdata\local\programs\python\python36-32\lib\site-packages\setuptools\extern\__init__.py", line 1, in <module>
from pkg_resources.extern import VendorImporter
File "c:\users\developer\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 3017, in <module>
#_call_aside
File "c:\users\developer\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 3003, in _call_aside
f(*args, **kwargs)
File "c:\users\developer\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 3045, in _initialize_master_working_set
dist.activate(replace=False)
File "c:\users\developer\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 2577, in activate
declare_namespace(pkg)
File "c:\users\developer\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 2151, in declare_namespace
_handle_ns(packageName, path_item)
File "c:\users\developer\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 2091, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "c:\users\developer\appdata\local\programs\python\python36-32\lib\site-packages\pkg_resources\__init__.py", line 2120, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\DEVELO~1\AppData\Local\Temp\pip-build-91vxtz3t\googleapis-common-protos\
I had the same problem as you and found a solution on the Google Platform Git.
In my case, it was because pip was not up-to-date. Just do :
pip install --upgrade pip
pip install --upgrade setuptools
pip install google-cloud
Total python noob here, I want to run my .py flask api file, i cd to my directory, activate my python virtual env, then i try run.py
Issue is that it prints:
$ python run.py
Traceback (most recent call last): File "run.py", line 1, in
from flask_sqlalchemy import SQLAlchemy ImportError: No module named flask_sqlalchemy
As far as im aware as im in my virtualenv and have my packages installed, this shouldnt happen. Trying to pip3 install on any packages shows them as already existing.
To further assist with the issue, i tried to run the script inside pycharm and i get the following error prints in the log:`Traceback (most recent call last):
File "/Users/Jack/Developer/Python/lift_api/run.py", line 26, in <module>
sqlAlchemy.create_all()
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1007, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 999, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 941, in get_engine
return connector.get_engine()
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 543, in get_engine
self._engine = rv = sqlalchemy.create_engine(info, **options)
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/sqlalchemy/engine/__init__.py", line 387, in create_engine
return strategy.create(*args, **kwargs)
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 80, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 554, in dbapi
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'`
Anyone have an idea?
To run your code with python 3.x use python3 command.
python3 run.py
What is saying what it needs - psycopg2. If you are on Ubuntu it can help:
sudo apt install libpq-dev python-dev
Then don't forget to install flask-sqlalchemy and other libraries while your virtualenv activated.
Whenever I try to install anything using pip I get the following error:
$ sudo pip install --upgrade pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==7.0.3', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 558, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2682, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2355, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2361, in resolve
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/wheel.py", line 35, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/_vendor/__init__.py", line 92, in load_module
raise ImportError("No module named '%s'" % (name,))
ImportError: No module named 'pip._vendor.distlib.scripts'
This also happens when I try to upgrade pip, install sphinx or basically any install/upgrade option using pip.
I am running Ubuntu 15.10 and using Python 2.7.10
StackOverflow has said this is a duplicate, and that there is a solution at ImportError: No module named 'pip._vendor.distlib.scripts' when I try to install fabric by python pip however the recommend solution on this post is not actually a soltuion. It does not solve my issue, nor does it appear to solve the original posters problem.
Try this:
sudo pip install --upgrade --no-use-wheel pip
[root#ip-172-31-34-8 ec2-user]# sudo pip install -U boto
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3020, in <module>
working_set = WorkingSet._build_master()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 616, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 629, in _build_from_requirements
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 807, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==6.1.1
If you are installing on a fresh EC2 machine, which I guess from the first line of your code, you may not have pip installed.
For recent versions of AWS Linux AMI, you may use easy_install instead:
sudo easy_install pip
And then:
sudo easy_install boto3
Or:
sudo pip install boto3