cannot build up a django project - python

every time I tried to build a django project. I have no initialized files like manage.py in my project.
Then I tried to create the project on command line, I got this:
C:\Python34\Lib\site-packages\Django-1.9.3-py3.4.egg\django\bin> python .\django-admin.py startproject "MySite"
Traceback (most recent call last):
File ".\django-admin.py", line 2, in <module>
from django.core import management
File "C:\Python34\lib\site-packages\django-1.9.3-py3.4.egg\django\core\management\__init__.py", line 10, in <module>
from django.apps import apps
File "C:\Python34\lib\site-packages\django-1.9.3-py3.4.egg\django\apps\__init__.py", line 1, in <module>
from .config import AppConfig
File "C:\Python34\lib\site-packages\django-1.9.3-py3.4.egg\django\apps\config.py", line 6, in <module>
from django.utils.module_loading import module_has_submodule
File "C:\Python34\lib\site-packages\django-1.9.3-py3.4.egg\django\utils\module_loading.py", line 67, in <module>
from importlib.util import find_spec as importlib_find
ImportError: cannot import name 'find_spec'
Somebody could help me? I really appreciate your help.
ps: python3.4, django_1.9

U need to put your code here because it seems you are having too many import errors

You are trying to create a Django project from within your Python installation (C:\Python34\Lib\site-packages\Django-1.9.3-py3.4.egg\django\bin>).
Try going to your home directory and trying there. django-admin should be in C:\Python34\Scripts\ and that should be in your PATH so you should be able to call it from anywhere.
PS Use virtualenv

Related

I have broken my poetry installation, and I don't know where to begin to fix it

I was using poetry in combination with pyenv for some hobby projects. I created some virtualenvs with pyenv inside some poetry hobby projects. For some reason, I deleted some of these python installs that broke the virtualenvs within these projects and now poetry won't work anymore. I'm getting this message when I try to start poetry. I'm using Linux Mint 20.1:
/home/milkman/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
"program uses threads.", RuntimeWarning)
Traceback (most recent call last):
File "/home/milkman/.poetry/bin/poetry", line 16, in <module>
from poetry.console import main
File "/home/milkman/.poetry/lib/poetry/console/__init__.py", line 1, in <module>
from .application import Application
File "/home/milkman/.poetry/lib/poetry/console/application.py", line 7, in <module>
from .commands.about import AboutCommand
File "/home/milkman/.poetry/lib/poetry/console/commands/__init__.py", line 4, in <module>
from .check import CheckCommand
File "/home/milkman/.poetry/lib/poetry/console/commands/check.py", line 2, in <module>
from poetry.factory import Factory
File "/home/milkman/.poetry/lib/poetry/factory.py", line 18, in <module>
from .repositories.pypi_repository import PyPiRepository
File "/home/milkman/.poetry/lib/poetry/repositories/pypi_repository.py", line 33, in <module>
from ..inspection.info import PackageInfo
File "/home/milkman/.poetry/lib/poetry/inspection/info.py", line 25, in <module>
from poetry.utils.env import EnvCommandError
File "/home/milkman/.poetry/lib/poetry/utils/env.py", line 23, in <module>
import virtualenv
File "/home/milkman/.poetry/lib/poetry/_vendor/py2.7/virtualenv/__init__.py", line 3, in <module>
from .run import cli_run, session_via_cli
File "/home/milkman/.poetry/lib/poetry/_vendor/py2.7/virtualenv/run/__init__.py", line 13, in <module>
from .plugin.activators import ActivationSelector
File "/home/milkman/.poetry/lib/poetry/_vendor/py2.7/virtualenv/run/plugin/activators.py", line 6, in <module>
from .base import ComponentBuilder
File "/home/milkman/.poetry/lib/poetry/_vendor/py2.7/virtualenv/run/plugin/base.py", line 5, in <module>
from backports.entry_points_selectable import entry_points
ImportError: No module named entry_points_selectable
I have no idea where to start to fix this. Anytime I try a command with poetry I get this same message. Can anyone point me in the right direction?
Thank you!
May be you have deleted some library files. You can try removing poetry and all libraries that your app is using. Start fresh installation of poetry.
You can use pip to install and uninstall.
Other wise start a new project from fresh.
It appears you accidentally deleted some of the library's functions. Try just removing it and reinstalling.

Using cms_shiny in a django project error "cannot import name 'six' from 'django.utils'..."

I am trying to create a web app using django and I would like part of it to show a shiny dashboard. Recently I have been trying to use djangocms-shiny-app 0.1.3 package to accomplish this; however, after following the setup guide for the package, I am running into an error
File "C:\Users\rdkbh\AppData\Local\Programs\Python\Python39\lib\site-packages\cms_shiny\models.py", line 2, in <module>
from filer.fields.image import FilerImageField
File "C:\Users\rdkbh\AppData\Local\Programs\Python\Python39\lib\site-packages\filer\fields\image.py", line 4, in <module>
from .. import settings
File "C:\Users\rdkbh\AppData\Local\Programs\Python\Python39\lib\site-packages\filer\settings.py", line 11, in <module>
from .utils.loader import load_object
File "C:\Users\rdkbh\AppData\Local\Programs\Python\Python39\lib\site-packages\filer\utils\loader.py", line 13, in <module>
from django.utils import six
ImportError: cannot import name 'six' from 'django.utils' (C:\Users\rdkbh\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\__init__.py)
If anyone knows what is causing the error (Based on the error message I believe it is something to do with cms_shiny) and how to fix it or if there are any better packages for integrating a shiny app into Django I would greatly appreciate it.
Thanks in advance!

No module named 'instance' while trying to run a Flask app

Traceback (most recent call last):
File "manage.py", line 6, in <module>
from app import create_app, db
File "C:\Users\miran\Dropbox\PyReddit-master\app\__init__.py", line 6, in <module>
from instance.config import app_config
ModuleNotFoundError: No module named 'instance'
I am testing out this repository (https://github.com/tuvtran/PyReddit) and it keeps telling me there is no module instance, I have searched but found nothing that helped the error. The venv is in the same folder as the script.
Essentially this is occurring because the app\__init__.py is is importing a file in the instance directory. As per the Flask documentation, this directory normally contains instance configuration overrides default configurations.
Unfortunately, the project currently saves its default configurations in this directory, but it is not checked into Git (see .gitignore). To fix this:
Remove from instance.config import app_config
Add a configuration file following these instructions
Import the configuration file you just created
Replace app.config.from_object(app_config[config_name]) with app.config.from_object(your_configuration)

Django site fails with "ImportError: cannot import name '_BACKCOMPAT_MAGIC_NUMBER'" after working fine for months

I have Django app on hosting which has been running since June last year. I forgot to buy credits and so my hosting provider freezed my app. I bought new credits but I does not start. I simply get: "502 Bad Gateway".
I checked the logs, and in python.log found possible problem. Here is the traceback:
Traceback (most recent call last):
File "/srv/venv/bin/gunicorn", line 7, in <module>
from gunicorn.app.wsgiapp import run
File "/srv/venv/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 10, in <module>
from gunicorn.app.base import Application
File "/srv/venv/lib/python3.5/site-packages/gunicorn/app/base.py", line 12, in <module>
from gunicorn import util
File "/srv/venv/lib/python3.5/site-packages/gunicorn/util.py", line 12, in <module>
import pkg_resources
File "/srv/venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 26, in <module>
import zipfile
File "/opt/python/lib/python3.5/zipfile.py", line 9, in <module>
import importlib.util
File "/srv/venv/lib/python3.5/importlib/util.py", line 7, in <module>
from ._bootstrap_external import MAGIC_NUMBER, _BACKCOMPAT_MAGIC_NUMBER
ImportError: cannot import name '_BACKCOMPAT_MAGIC_NUMBER'
As far as I know there weren't any changes prior to this problem. Moreover I cannot find similar issues here on SO or elsewhere on the net.
importlib should be part of Python 3 so I thought I could try commenting out the import from "/opt/python/lib/python3.5/zipfile.py" but I don't have write permissions on the server.
I also tried recreating the venv which did not help. Same with switching Python runtime to either 3.4 or 3.6 in hosting's administration.

ImportError: cannot import name signals when importing wsgi file in Django 1.10

I'm getting the following error trying to run Django using apache:
mod_wsgi (pid=3294): Target WSGI script '/www/cocurate2_dev/startup.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=3294): Exception occurred processing WSGI script '/www/cocurate2_dev/startup.wsgi'.
Traceback (most recent call last):
File "/www/cocurate2_dev/startup.wsgi", line 3, in <module>
from django.core.wsgi import get_wsgi_application
File "/www/cocurate2_dev/components/lib/python2.7/site-packages/django/core/wsgi.py", line 2, in <module>
from django.core.handlers.wsgi import WSGIHandler
File "/www/cocurate2_dev/components/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 10, in <module>
from django import http
File "/www/cocurate2_dev/components/lib/python2.7/site-packages/django/http/__init__.py", line 5, in <module>
from django.http.response import (
File "/www/cocurate2_dev/components/lib/python2.7/site-packages/django/http/response.py", line 13, in <module>
from django.core.serializers.json import DjangoJSONEncoder
File "/www/cocurate2_dev/components/lib/python2.7/site-packages/django/core/serializers/__init__.py", line 23, in <module>
from django.core.serializers.base import SerializerDoesNotExist
File "/www/cocurate2_dev/components/lib/python2.7/site-packages/django/core/serializers/base.py", line 4, in <module>
from django.db import models
File "/www/cocurate2_dev/components/lib/python2.7/site-packages/django/db/models/__init__.py", line 4, in <module>
from django.db.models import signals # NOQA
ImportError: cannot import name signals
Everything works find when using manage.py runserver. I've updated the wsgi file to be the same as the default one from django 1.10.
I've checked that signals.py exists inside django, I've also cleaned .pyc files.
It turns out there actually was a file missing from the django installation for various reasons, it just wasn't signals.py but rather something it imported.
You can debug problems like this by running python with -v or -vv switch to make output verbose. I was able to see that it was trying to import another file from signals.py.
I had this error when my Django 1.10 install was downgraded to Django 1.6 by a third party.
After removing it and re-installing the correct version of Django, everything worked like a champ.

Categories

Resources