Re: [sqlalchemy] PyDev throwing errors in the SQLAlchemy Library
I've never used PyDev, but if it effectively adds the folder that you've specified in that screenshot to PYTHONPATH, then I suspect that is the problem. What happens if you remove that External Library, and try to run the following script: import sqlalchemy print sqlalchemy.__file__ Simon On Sat, Aug 16, 2014 at 2:41 PM, Zakaria Boulouard zboulou...@gmail.com wrote: Hello Michael and thanks for your help, If there is anyway to make it work in PyDev that would be great because I want to integrate a similar code into a bigger project and PyDev would be more suitable. I guess importing the SQLAlchemy lib was the way it should be, I even put it as forced lib, you can check the attached picture. If it wouldn't bother you, I would like to invite you to take a look using teamviewer and see what is going on. Thanks again! 2014-08-16 13:25 GMT+01:00 Michael Bayer mike...@zzzcomputing.com: how are you running the script? there’s an environmental issue that is causing SQLAlchemy to be imported improperly. This is probably some PyDev issue. If you install SQLAlchemy in a virtualenv normally and run the script from the console it should be fine (runs over here OK). On Aug 16, 2014, at 4:13 AM, Zakaria Boulouard zboulou...@gmail.com wrote: Hello guys, I am new to SQLAlchemy and I wanted to try an example using a MySQL database and PyDev as an IDE but when I run it, PyDev gives me the following error : Traceback (most recent call last): File /usr/lib/python2.7/site.py, line 68, in module import os File /usr/lib/python2.7/os.py, line 49, in module import posixpath as path File /usr/lib/python2.7/posixpath.py, line 17, in module import warnings File /usr/lib/python2.7/warnings.py, line 8, in module import types File /home/zakaria/Bureau/Python/SQLAlchemy-0.9.7/lib/sqlalchemy/types.py, line 21, in module from .sql.type_api import ( ValueError: Attempted relative import in non-package What did I do wrong? And how can I fix it? Please find attached the test file Personne.py and thanks for your help! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. Personne.py -- You received this message because you are subscribed to a topic in the Google Groups sqlalchemy group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/eJ2Z8QBAEzU/unsubscribe. To unsubscribe from this group and all its topics, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- Zakaria BOULOUARD Ingénieur d'État en Génie Informatique École Nationale des Sciences Appliquées Khouribga N° Téléphone: (+212)662193321 / (+212)668695440 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] PyDev throwing errors in the SQLAlchemy Library
Hi Simon and thanks for your help. I just tried what you said and it doesn't work! What I did though (AND IT WORKED!) is that I have updated my OS (Ubuntu) from 12.04 to 14.04 which has Python3 as default and I run my project with it. 2014-08-18 10:31 GMT+01:00 Simon King si...@simonking.org.uk: I've never used PyDev, but if it effectively adds the folder that you've specified in that screenshot to PYTHONPATH, then I suspect that is the problem. What happens if you remove that External Library, and try to run the following script: import sqlalchemy print sqlalchemy.__file__ Simon On Sat, Aug 16, 2014 at 2:41 PM, Zakaria Boulouard zboulou...@gmail.com wrote: Hello Michael and thanks for your help, If there is anyway to make it work in PyDev that would be great because I want to integrate a similar code into a bigger project and PyDev would be more suitable. I guess importing the SQLAlchemy lib was the way it should be, I even put it as forced lib, you can check the attached picture. If it wouldn't bother you, I would like to invite you to take a look using teamviewer and see what is going on. Thanks again! 2014-08-16 13:25 GMT+01:00 Michael Bayer mike...@zzzcomputing.com: how are you running the script? there’s an environmental issue that is causing SQLAlchemy to be imported improperly. This is probably some PyDev issue. If you install SQLAlchemy in a virtualenv normally and run the script from the console it should be fine (runs over here OK). On Aug 16, 2014, at 4:13 AM, Zakaria Boulouard zboulou...@gmail.com wrote: Hello guys, I am new to SQLAlchemy and I wanted to try an example using a MySQL database and PyDev as an IDE but when I run it, PyDev gives me the following error : Traceback (most recent call last): File /usr/lib/python2.7/site.py, line 68, in module import os File /usr/lib/python2.7/os.py, line 49, in module import posixpath as path File /usr/lib/python2.7/posixpath.py, line 17, in module import warnings File /usr/lib/python2.7/warnings.py, line 8, in module import types File /home/zakaria/Bureau/Python/SQLAlchemy-0.9.7/lib/sqlalchemy/types.py, line 21, in module from .sql.type_api import ( ValueError: Attempted relative import in non-package What did I do wrong? And how can I fix it? Please find attached the test file Personne.py and thanks for your help! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. Personne.py -- You received this message because you are subscribed to a topic in the Google Groups sqlalchemy group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/eJ2Z8QBAEzU/unsubscribe. To unsubscribe from this group and all its topics, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- Zakaria BOULOUARD Ingénieur d'État en Génie Informatique École Nationale des Sciences Appliquées Khouribga N° Téléphone: (+212)662193321 / (+212)668695440 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to a topic in the Google Groups sqlalchemy group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/eJ2Z8QBAEzU/unsubscribe. To unsubscribe from this group and all its topics, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- Zakaria BOULOUARD Ingénieur d'État en Génie Informatique École Nationale des Sciences Appliquées Khouribga N° Téléphone: (+212)662193321 / (+212)668695440 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this
[sqlalchemy] PyDev throwing errors in the SQLAlchemy Library
Hello guys, I am new to SQLAlchemy and I wanted to try an example using a MySQL database and PyDev as an IDE but when I run it, PyDev gives me the following error : Traceback (most recent call last): File /usr/lib/python2.7/site.py, line 68, in module import os File /usr/lib/python2.7/os.py, line 49, in module import posixpath as path File /usr/lib/python2.7/posixpath.py, line 17, in module import warnings File /usr/lib/python2.7/warnings.py, line 8, in module import types File /home/zakaria/Bureau/Python/SQLAlchemy-0.9.7/lib/sqlalchemy/types.py, line 21, in module from .sql.type_api import ( ValueError: Attempted relative import in non-package What did I do wrong? And how can I fix it? Please find attached the test file Personne.py and thanks for your help! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. #!/usr/bin/python2.7 # -*-coding:Utf-8 -* ''' Created on 13 août 2014 @author: zakaria ''' from sqlalchemy import create_engine from sqlalchemy.ext.declarative.api import declarative_base from sqlalchemy.orm.session import sessionmaker from sqlalchemy import Column, Integer, String #Chaîne de connexion engine = create_engine('mysql://root:root@localhost:3306/python', echo=False) #Session Session = sessionmaker(bind=engine) session = Session() Base = declarative_base() class Personne(Base): #Nom de la table __tablename__ = 'Personne' #Attributs id = Column(Integer, primary_key=True) nom = Column(String(50)) prenom = Column(String(50)) #Constructeur def __init__(self, nom, prenom): self.nom = nom self.prenom = prenom #Méthodes def __repr__(self): return Personne(%s, %s) % (self.nom, self.prenom) #Fin Classe Personne #Ajout d'une seule entrée new_record = Personne(TOTO, Zak) session.add(new_record) session.commit() #Ajout de plusieurs entrées list_of_records = [Personne(TOTO, Med), Personne(LALA, Mia)] session.add_all(list_of_records) session.commit() #Requêtage records = session.query(Personne).filter_by(nom='TOTO') for person in records: print person print or\n all_records = session.query(Personne).all() for p1 in all_records: print p1
Re: [sqlalchemy] PyDev throwing errors in the SQLAlchemy Library
how are you running the script? there's an environmental issue that is causing SQLAlchemy to be imported improperly. This is probably some PyDev issue. If you install SQLAlchemy in a virtualenv normally and run the script from the console it should be fine (runs over here OK). On Aug 16, 2014, at 4:13 AM, Zakaria Boulouard zboulou...@gmail.com wrote: Hello guys, I am new to SQLAlchemy and I wanted to try an example using a MySQL database and PyDev as an IDE but when I run it, PyDev gives me the following error : Traceback (most recent call last): File /usr/lib/python2.7/site.py, line 68, in module import os File /usr/lib/python2.7/os.py, line 49, in module import posixpath as path File /usr/lib/python2.7/posixpath.py, line 17, in module import warnings File /usr/lib/python2.7/warnings.py, line 8, in module import types File /home/zakaria/Bureau/Python/SQLAlchemy-0.9.7/lib/sqlalchemy/types.py, line 21, in module from .sql.type_api import ( ValueError: Attempted relative import in non-package What did I do wrong? And how can I fix it? Please find attached the test file Personne.py and thanks for your help! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. Personne.py -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] PyDev throwing errors in the SQLAlchemy Library
Hello Michael and thanks for your help, If there is anyway to make it work in PyDev that would be great because I want to integrate a similar code into a bigger project and PyDev would be more suitable. I guess importing the SQLAlchemy lib was the way it should be, I even put it as forced lib, you can check the attached picture. If it wouldn't bother you, I would like to invite you to take a look using teamviewer and see what is going on. Thanks again! 2014-08-16 13:25 GMT+01:00 Michael Bayer mike...@zzzcomputing.com: how are you running the script? there’s an environmental issue that is causing SQLAlchemy to be imported improperly. This is probably some PyDev issue. If you install SQLAlchemy in a virtualenv normally and run the script from the console it should be fine (runs over here OK). On Aug 16, 2014, at 4:13 AM, Zakaria Boulouard zboulou...@gmail.com wrote: Hello guys, I am new to SQLAlchemy and I wanted to try an example using a MySQL database and PyDev as an IDE but when I run it, PyDev gives me the following error : Traceback (most recent call last): File /usr/lib/python2.7/site.py, line 68, in module import os File /usr/lib/python2.7/os.py, line 49, in module import posixpath as path File /usr/lib/python2.7/posixpath.py, line 17, in module import warnings File /usr/lib/python2.7/warnings.py, line 8, in module import types File /home/zakaria/Bureau/Python/SQLAlchemy-0.9.7/lib/sqlalchemy/types.py, line 21, in module from .sql.type_api import ( ValueError: Attempted relative import in non-package What did I do wrong? And how can I fix it? Please find attached the test file Personne.py and thanks for your help! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. Personne.py -- You received this message because you are subscribed to a topic in the Google Groups sqlalchemy group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/eJ2Z8QBAEzU/unsubscribe. To unsubscribe from this group and all its topics, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- Zakaria BOULOUARD Ingénieur d'État en Génie Informatique École Nationale des Sciences Appliquées Khouribga N° Téléphone: (+212)662193321 / (+212)668695440 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.