I have this module
import os
import sys
sys.path.append("C:\pysec-master")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pysec-master.settings")
from pysec.models import *
"""get a file from the index. it may or may not be present on our hard disk. if it's not, it will be downloaded
the first time we try to access it, or you can call .download() explicitly"""
filing = Index.objects.filter(form='10-K',cik=1090872).order_by('-date')[0]
print filing.name
"""initialize XBRL parser and populate an attribute called fields with a dict of 50 common terms"""
x = latest.xbrl()
print x.fields['FiscalYear']
print x.fields
"""fetch arbitrary XBRL tags representing eiter an Instant or a Duration in time"""
print 'Tax rate', x.GetFactValue('us-gaap:EffectiveIncomeTaxRateContinuingOperations','Duration')
if x.loadYear(1):
"""Most 10-Ks have two or three previous years contained in them for the major values. This call switches the contexts
to the prior year (set it to 2 or 3 instead of 1 to go back further) and reloads the fundamental concepts.
Any calls to GetFactValue will use that year's value from that point on."""
print x.fields['FiscalYear']
print x.fields
print 'Tax rate', x.GetFactValue('us-gaap:EffectiveIncomeTaxRateContinuingOperations','Duration')
I am trying to run it for a week now and whenever i hit F5 to run it i get this error:
Traceback (most recent call last):
File "C:\pysec-master\pysec\example.py", line 8, in <module>
from pysec.models import *
File "C:\pysec-master\pysec\models.py", line 4, in <module>
from django.db import models
File "C:\Python27\lib\site-packages\django\db\models\__init__.py", line 5, in <module>
from django.db.models.query import Q
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 17, in <module>
from django.db.models.deletion import Collector
File "C:\Python27\lib\site-packages\django\db\models\deletion.py", line 4, in <module>
from django.db.models import signals, sql
File "C:\Python27\lib\site-packages\django\db\models\sql\__init__.py", line 4, in <module>
from django.db.models.sql.subqueries import *
File "C:\Python27\lib\site-packages\django\db\models\sql\subqueries.py", line 12, in <module>
from django.db.models.sql.query import Query
File "C:\Python27\lib\site-packages\django\db\models\sql\query.py", line 22, in <module>
from django.db.models.sql import aggregates as base_aggregates_module
File "C:\Python27\lib\site-packages\django\db\models\sql\aggregates.py", line 9, in <module>
ordinal_aggregate_field = IntegerField()
File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", line 116, in __init__
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 54, in __getattr__
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'pysec-master.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named pysec-master.settings
If you need any other module from the projects please tell me and i will edit my question and put it in. The original files from the project are here.
The project is named pysec-master
and it is on this directory: C:\pysec-master
The project is structured like this
C:\pysec-master(file)
|__C:\pysec-master\local_settings.py
|__C:\pysec-master\manage.py
|__C:\pysec-master\settings.py
|__C:\Python27\pysec(file)
|__C:\pysec-master\pysec\__init__.py
|__C:\pysec-master\pysec\example.py
|__C:\pysec-master\pysec\models.py
|__C:\pysec-master\pysec\xbrl.py
|__C:\pysec-master\pysec\xbrl_fundamentals.py
My environment variables are:
Path
--> C:\Python27;C:\Python27\Scripts;C:\pysec-master
PYTHONPATH
--> C:\pysec-master;C:\;
When i type sys.path
i get
['C:\\Python27\\Lib\\idlelib', 'C:\\pysec-master', 'C:\\pysec-master\\pysec',
'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27',
'C:\\Python27\\lib\\site-packages', 'C:\\pysec-master']
I have checked:
- The environmental variables to be in accord
- Set the
DJANGO_MODULE_SETTINGS
So what is the problem and how can i fix it?