tree
├───pzApi
│ │ asgi.py
│ │ db.sqlite3
│ │ manage.py
│ │ settings.py
│ │ urls.py
│ │ wsgi.py
│ │ __init__.py
│ │
│ └───api
│ │ apps.py
│ │ funcs.py
│ │ urls.py
│ │ views.py
│ │ __init__.py
Procfile
release: python pzApi/manage.py migrate
web: gunicorn --bind 127.0.0.1:8000 pzApi.wsgi:application
I'm still trying to deploy this web app and after fixing the wsgi.py not found error by putting it in the same dir as manage.py, now I have another problem where the 'api' folder is not being found, any help is appreciated!
Related
I am struggling with the implementation of unittest for subdirectories. I have the following project
project
│ README.md
│ __init__.py
│
└───common
│ __init__.py
│ └───my_func
│ │ __init__.py
│ │ func1.py
│ │ func2.py
│
└───scripts
│ __init__.py
│ └───folder_1
│ │ __init__.py
│ │ code1.py
│ │ code2.py
│
│ └───folder_2
│ │ __init__.py
│ │ code3.py
│ │ code4.py
│ │
│ └───tests
│ │ └───test1
│ │ │ __init__.py
│ │ │ test_code3.py
│ │ │ test_code4.py
│ │ │
│ │ └───test2
│ │ │ __init__.py
│ │ │ test_code3.py
│ │ │ test_code4.py
I set the working directory to be ./project. In my code1.py file I import common.my_func.func1 and it runs normally.
Now, I am trying to implement some unittest functions in ./project/scripts/tests. To do so, I am using the coverage package and running the command: coverage run --source=scripts -m unittest discover scripts/tests. However, when doing so, I get the following error:
ModeluNotFoundError: No module named common.my_func
Weirdly speaking, the scripts works perfectly when I try to run it for one test folder only, and not the whole folder coverage run --source=scripts -m unittest discover scripts/tests/test1.
I tried multiple combinations of removing the source, getting more specific with the folder and on. Have any of you faced similar problems with python 3.8?
Thank you very much in advance,
I'm trying to build a very simple Web Scraper that scrapes from popular Job Boards and posts the jobs in a simple Django website.
In my Scrapy spider, I am trying to create a Django model object for every job scraped. But I'm having trouble importing the model in my Scrapy spider file.
This is my folder structure:
F:.
│ db.sqlite3
│ manage.py
│
├───jobs_board
│ asgi.py
│ settings.py
│ urls.py
│ wsgi.py
│ __init__.py
│
├───main
│ │ admin.py
│ │ apps.py
│ │ models.py
│ │ tests.py
│ │ urls.py
│ │ views.py
│ │ __init__.py
│ │
│ ├───migrations
│ │ 0001_initial.py
│ │ __init__.py
│ │
│ └───templates
│ └───main
│ home.html
│
└───scraper
│ scrapy.cfg
│ t.py
│ testing.md
│
└───scraper
│ items.py
│ middlewares.py
│ pipelines.py
│ settings.py
│ __init__.py
│
└───spiders
indeed.py
__init__.py
What I want to do is, if I run the spider "indeed.py", I want it to be able to import the main/models.py file. How would I achieve this?
Thank you for your help! :)
I am converting my python project into packages, with sub-packages, with modules. The tree structure is as shown below (sorry for the long tree). When I run run.py, it imports MyEnvironment.environment which in turn has statements like from station import Station. It is at this stage that I get an error saying ModuleNotFoundError: No module named 'station'. I am not able to figure why this is happening. Note that it work when I do sys.append('.\Environment'), but it should work without it since I already added __init__.py. Could someone help here?
C:.
├───.vscode
│ settings.json
│
└───DRLOD-Package
│ run.py
│ __init__.py
│
├───MyEnvironment
│ │ agv.py
│ │ environment.py
│ │ job.py
│ │ job_queue.py
│ │ parent_area.py
│ │ path_finding.py
│ │ pdnode.py
│ │ policy.py
│ │ request.py
│ │ station.py
│ │ stats.py
│ │ test.py
│ │ __init__.py
```
In environment.py use from .station import Station
in Django, my model.py is out of my App modules I want to import all the classes from that model.py to all modules. I searched a lot I didn't get anything can anyone help me
here is my directory
C:
│ manage.py
│ **models.py**
│ mysqlclient-1.4.6-cp39-cp39-win_amd64.whl
│
│
├───myshop
│ │ asgi.py
│ │ settings.py
│ │ urls.py
│ │ wsgi.py
│ │ __init__.py
│ │
├───products
│ │ admin.py
│ │ apps.py
│ │ tests.py
│ │ views.py
│ │ __init__.py
│ │
│ ├───migrations
│ │ │ __init__.py
I got the error:
File ".\main.py", line 3, in <module>
from app.core import config
ModuleNotFoundError: No module named 'app'
in the line 3 of main.py:
from app.core import config
I have tried the left empty the file app/init.py and with the next:
from .core import config
My structure folder is:
backend
│
└───app
│ .env
│ main.py
│ __init__.py
│
├───api
│ __init__.py
│
├───core
│ config.py
│ __init__.py
│
├───db
│ base.py
│ base_class.py
│ __init__.py
│
├───db_models
│ association_tables.py
│ team.py
│ user.py
│ __init__.py
│
└───schema
│ mutation.py
│ query.py
│ __init__.py
│
├───team
│ mutations.py
│ queries.py
│ types.py
│ __init__.py
│
└───user
mutations.py
queries.py
types.py
__init__.py
I'd due to problem with absolute/relative reference. I use PyCharm and I don't have alarm about the reachable or not of the modules.
thanks for advance
I rebuilt your structure and this should do the trick:
from core import config