Search code examples
pythonsqlalchemyvagrantvirtual-machine

Errors given when trying to install SQLAlchemy in a vagrant VM


Inside the vagrant box after typing, vagrant ssh i tried to run the following two lines,

import sys
from sqlalchemy import Column, ForeignKey, Integer, String, engine

which gave the following error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'sqlalchemy'

When i try to install sqlalchemy using following code pip install SQLAlchemy it install the app but no change to the outcome. when i try pip3 install SQLAlchemy it gives the following error.

Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 7, in <module>
    from pip._internal.cli.main import main
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line
57
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

Solution

  • SQLAlchemy 1.4 requires either Python 2.7 or Python3.6+. Your server is running Python3.5. Try pip install --upgrade 'sqlalchemy<1.4'

    I tried as suggested in the comment section and now it's working like a charm.