Pycharm can't find Thrift ttypes file

1.3k views Asked by At

Short, problem description: When I try to run/debug a pylons project using paster via PyCharm it can't find the Thrift ttypes module that is being imported. If I run paster manually it works fine. The error message is just:

File "/myproj/lib/timetools/__init__.py", line 13, in <module>
  import lib.thrift.common.international.ttypes as international_ttypes
port Error: No module named internation.ttypes

Long description: I am trying out PyCharm for the first time. I have downloaded and installed it on Mac OSX Yosemite and pointed it at the project directory and I have configured the virtual environment (python interpreter).

Project structure (the part relevant to this question) looks like:

/myproj/lib/timetools/__init__.py
/myproj/lib/thrift/common/international.thrift
/myproj/build/py/lib/python2.6/site-packages/lib/thrift/common/international/ttypes.pyc
/myproj/mypylons/config/development.ini

My virtual environment is set to /myproj/build/py/bin/python.

If I go to my project root directory and run my activate script to use my virtual environment, I can successfully run:

paster serve config:/myproj/mypylons/config/development.ini

And the server starts up and responds on the appropriate port.

The way I configured PyCharm to run the pylons it tries to execute the following:

/myproj/build/py/bin/python "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py" --multiproc --client 127.0.0.1 --port 53432 --file /myproj/build/py/bin/paster serve config:/myproj/mypylons/config/development.ini

And I get the error above. It would seem that PyCharm can't find the international/ttypes.pyc file in my build directory even though it is included in the project. I tried setting the working directory to /myproj/build/py/lib/python2.6/site-packages but that didn't help.

As a note, when I look at the Project Interpreter configuration I do see the Thrift package there with a path of /myproj/build/py/lib/python2.6/site-packages.

Help!

1

There are 1 answers

0
wilfo On

From my experience it seems like you have to tell PyCharm exactly where the files are through the Project settings:

  1. Go to Settings and then to Project Structure
  2. Find the folder to which the ttypes are compiled to and click on it
  3. On the Mark as: line, above the directory tree window, click on Sources (should be colored blue)
  4. Click on 'OK' and you should be good to go

Hope it helps!