Inconsistent ImportError

28 views
Skip to first unread message

Brian Looker

unread,
Jun 30, 2015, 1:59:31 PM6/30/15
to pylons-...@googlegroups.com
I have two separate virtualenv's and Pyramid projects in which I am using WTForms. In one, the project is working fine. In the other, I am getting an import error. I'm working with Pyramid 1.5.7 on Linux Mint 17. 

I have installed and uninstalled with pip and easy_install, trying each based on threads I read elsewhere online. I have also uninstalled it and let setup.py install it as is demonstrated in the pyramid_blogr tutorial.

Looking at the output of when running the setup.py develop command, I notice that the working project has a different output for WTForms than the non-working project. I think this might be a clue, but I do not have the vocab to know what to search for online if I were to search there. Can any of you help me figure out how I can get the other project working?

Here's the setup.py develop output of the working project for WTForms:

Using <virtualenv directory>/lib/python2.7/site-packages
Searching for WTForms==2.0.2
Best match: WTForms 2.0.2
Adding WTForms 2.0.2 to easy-install.pth file

Here's the nonworking project:

Using <other virtualenv directory>/lib/python2.7/site-packages
Searching for WTForms==2.0.2
Best match: WTForms 2.0.2
Processing WTForms-2.0.2-py2.7.egg
WTForms 2.0.2 is already the active version in easy-install.pth

Relatedly, the easy-install.pth file for the working project does not include WTForms 2.0.2, even after running setup.py develop, while the non-working easy-install.pth includes ./WTForms-2.0.2-py2.7.egg. If I delete it from this file and run setup.py develop again, it is put back into the easy-install.pth file.

Any guidance would be appreciated.

Vincent Catalano

unread,
Jun 30, 2015, 3:22:58 PM6/30/15
to pylons-...@googlegroups.com
Just going over basics here but did you activate the environments before running `python setup.py develop`?

Also, what happens when you install the dependencies using pip? Do you get any errors?

Was WTForms installed globally by chance?

-Vincent

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.



--
Vincent Catalano
Software Engineer and Web Developer,
(520).603.8944

Brian Looker

unread,
Jun 30, 2015, 3:56:15 PM6/30/15
to pylons-...@googlegroups.com
Hi Vincent,

Yep, I've activated both environments. My initial install of dependencies for the non-working project was from a text file of requirements I created using pip freeze on the working project. I had no errors with the installation. 

I didn't mention it initially, but I have wtforms listed in my requires list in setup.py in both projects.

And I just did a quick check pulling up the system Python interpreter and could not import wtforms, so I believe I only have it installed in my virtual environments.

Vincent Catalano

unread,
Jun 30, 2015, 4:16:14 PM6/30/15
to pylons-...@googlegroups.com
What version do you have configured in your setup.py file for WTForms? Is it the same or different than the one in your requirements.txt?

Also, are you being explicit with your dependency versions (i.e. WTForms==2.0.2)?

Lastly, did you install dependencies first with pip and then with setup.py?

Jonathan Vanasco

unread,
Jun 30, 2015, 4:36:29 PM6/30/15
to pylons-...@googlegroups.com
Some possibly dumb questions:

1. are you failing to start it with the same .ini
2. can you start the failed project using the working virtualenv, and vice versa?
3. have you tried with a new virtualenv, and comparing?
4. have you tried deleting all the .pyc files?  sometimes an old one will somehow get stuck and never regenerate, which can cause odd issues like this.
5. any chance you updated python between creating the virtualenvs?  if you update the interpreter, you usually need to reinstall every package.  

Oliver

unread,
Jun 30, 2015, 4:41:52 PM6/30/15
to pylons-...@googlegroups.com
I have experienced that `python setup.py develop` behaves different than `pip install -e .`

some times I got several versions of the same package installed by mixing these two methods.
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> pylons-discus...@googlegroups.com <mailto:pylons-discus...@googlegroups.com>.
> To post to this group, send email to pylons-...@googlegroups.com <mailto:pylons-...@googlegroups.com>.

Brian Looker

unread,
Jul 1, 2015, 9:02:28 AM7/1/15
to pylons-...@googlegroups.com

Thank you for your reply and help, Vincent. I've answered your questions inline.

On Tuesday, June 30, 2015 at 3:16:14 PM UTC-5, Vincent Catalano wrote:
What version do you have configured in your setup.py file for WTForms? Is it the same or different than the one in your requirements.txt?
I have added the version specification to the setup.py file, run setup.py develop, but see no change. The version (2.0.2) matches the one in requirements.txt.
 
Also, are you being explicit with your dependency versions (i.e. WTForms==2.0.2)?
 On the initial installation using pip from the requirement.txt file, and now with the setup.py file.
 
Lastly, did you install dependencies first with pip and then with setup.py?
I initially installed all of the dependencies using pip and the requirements.txt file. 

Brian Looker

unread,
Jul 1, 2015, 9:32:41 AM7/1/15
to pylons-...@googlegroups.com
Thank you for the reply and your help, Jonathan. I've answered your questions inline.

Oh! Deleting the .pyc files did it. Thank you very much! I remember learning about the potential for that problem at a Python Bootcamp, but hadn't encountered it before.

I appreciate everyone's help.


On Tuesday, June 30, 2015 at 3:36:29 PM UTC-5, Jonathan Vanasco wrote:
Some possibly dumb questions:

1. are you failing to start it with the same .ini
The two projects have different .ini files specific to each project, though they are very similar in their Pyramid setup. 
 
2. can you start the failed project using the working virtualenv, and vice versa?
Thank you--I hadn't thought to try that. The failed project is failed in both virtualenvs, but the working project works in both virtualenvs.
 
3. have you tried with a new virtualenv, and comparing?
Not yet, but I'll put that on the to-do list. Given what I found with your suggestion of running each project in the other's virtualenv, I'm thinking the issue is somewhere in the failed project.

Jonathan Vanasco

unread,
Jul 1, 2015, 10:59:48 AM7/1/15
to pylons-...@googlegroups.com


On Wednesday, July 1, 2015 at 9:32:41 AM UTC-4, Brian Looker wrote:
Oh! Deleting the .pyc files did it. Thank you very much! I remember learning about the potential for that problem at a Python Bootcamp, but hadn't encountered it before.

I put a dumb little file called 'cleanup.py' in every project.  it's just some crude shell commands to delete all the .pyc .pyo files and everything under 'data' so I can quickly start fresh.

it has solved so many odd situations like you describe!

Brian Looker

unread,
Jul 1, 2015, 1:58:31 PM7/1/15
to pylons-...@googlegroups.com
That's a good idea.

I do have a correction. In addition to deleting the .pyc files, I was playing with my import statements. The problem returned after uncommenting one of the wtforms imports I'd missed.

This whole mess was caused by a typo--I apologize for taking up your time. Turns out that wtforms and wftorms are very similar-looking words. I'm not surprised my app couldn't find module wftorms. 
Reply all
Reply to author
Forward
0 new messages