Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to provide 'make directory as source root' from pyCharm to terminal

I have some problems with migrating to production:

cabox@box-codeanywhere:~/workspace/PEP$ python ./dev_scrapers/jordan.py                                                                                                                                                                       
Traceback (most recent call last):                                                                                                                                                                                                            
  File "./dev_scrapers/jordan.py", line 3, in <module>                                                                                                                                                                                        
    from utils import create_entity, create_id, custom_opener                                                                                                                                                                                 
ImportError: No module named utils

i have used pyCharm with button 'make directory as source root' how to execute such command in terminal?

like image 540
Jesus_Maria Avatar asked May 26 '15 14:05

Jesus_Maria


3 Answers

You should add your source root directory to PYTHONPATH:

export PYTHONPATH="${PYTHONPATH}:/your/source/root"
like image 175
Igor Pomaranskiy Avatar answered Oct 01 '22 01:10

Igor Pomaranskiy


You can set the environment variable PYTHONPATH within the terminal as suggested by the accepted answer. This has to be done every time you start a terminal. In the case you use a virtual environment, you can place the variable assignment, like export PYTHONPATH="/your/source/root", in the file venv/bin/activate. Where venv stands for the name of the virtual environment directory.

like image 23
Henrik Avatar answered Oct 01 '22 02:10

Henrik


I was able to set directory as root (and fix the unresolved import issue) doing the following:

from pycharm>Settings>Project>Project Structure select your project and from the file tree, select your django project directory then click the blue folder Source button to define the directory as your source.

like image 36
monkut Avatar answered Oct 01 '22 02:10

monkut