I installed the Kivy lib, and have been trying to get it to work all day.
I tried following the simple tutorial:
import kivy
kivy.require('1.9.0')
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()
When trying to run from file i get the following error:
Traceback (most recent call last):
File "random.py", line 1, in <module>
import kivy
File "C:\Python34\lib\site-packages\kivy\__init__.py", line 38, in <module>
from kivy.logger import Logger, LOG_LEVELS
File "C:\Python34\lib\site-packages\kivy\logger.py", line 61, in <module>
from random import randint
File "random.py", line 2, in <module>
from kivy.app import App
File "C:\Python34\lib\site-packages\kivy\app.py", line 315, in <module>
from kivy.config import ConfigParser
File "C:\Python34\lib\site-packages\kivy\config.py", line 272, in <module>
from kivy import kivy_config_fn
ImportError: cannot import name 'kivy_config_fn'
Press any key to continue . . .
Confusingly enough, it works in the interactive just fine... (able to build class and run app with exact same code)
Notes:
Already tried reinstalling
Installed Kivy from here
Specs:
Window 8.1
Python 3.4
Thanks in advance
Okay so after some googling, i finally found my answer.
I followed this guide and got everything to work:
How to use PTVS to develop and run Kivy applications
And also this from 2013 stating that you can't use Kivy as a regular module.
How to use PyDev to develop and run Kivy applications
Related
It's important to know that I am using pyinstaller to package python.
tkinter works perfectly fine when I package it with only:
import tkinter
root=tkinter.Tk()
root.mainloop()
but when I add some more of my code it shows the error:
Traceback (most recent call last):
File "exec", line 1, in <module>
import tkinter
File "C:\Program Files\Python38\lib\tkinter\__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: Module use of python39.dll conflicts with this version of Python.
These are all my imports:
import discord
import subprocess
from os import getcwd
import os
import pyautogui
from threading import *
import sys
I tried using only a tkinter window with no extra code and that worked!
But when I add the rest of my code it shows the error:
Traceback (most recent call last):
File "exec", line 1, in \<module\>
import tkinter
File "C:\\Program Files\\Python38\\lib\\tkinter\__init_\_.py", line 36, in \<module\>
import \_tkinter # If this fails your Python may not be configured for Tk
ImportError: Module use of python39.dll conflicts with this version of Python.
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.
I want to run my python program from command line but it gives me below error
ImportError: No module named 'main'
My folder structure is as below
Project
|-----main
|-----__init__.py
|-----S3Operations.py
|-----BusinessOperations.py
My init.py code is as below
import sys
from S3Operations import Models
sys.path.append("D:/code/Project/main")
if __name__ == '__main__':
s3=Models()
s3.test()
And my S3Operations.py code is
import os.path
from main import BusinessService
class ModelsMlS3(object):
def test(self):
print("Testing success")
When I run the program using command line i get the below error
$ python __init__.py
Traceback (most recent call last):
File "__init__.py", line 2, in <module>
from S3Operations import ModelsMlS3
File "D:\code\Project\main\S3Operations.py", line 11, in <module>
from main import BusinessService
ImportError: No module named 'main'
Can any one please suggest a solution for the same.
You just need to do:
import BusinessService # instead of `from main import BusinessService`
as in your project, there is no __init__.py file present in Project directory (which holds main.py).
For importing it like:
from main import BusinessService
you need to create __init__.py in the folder in order to make it as module.
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
I need to run multiple instances of odoo on my centos 7 server. So i needto use source insallation method for installing to install odoo as written in their documentation.
I was able to install odoo (git clonning to my system, installing dependencies, installing less css using npm) everything works fine for me till here.
After that they say i have to start running odoo using odoo.py script file as shown in the code sample below:
`./odoo.py -w <my_postgres_password> -r <postgres_user> --addons-path=addons,../mymodules --db-filter=mydb$`
But here i get into an error.
Traceback (most recent call last):
File "./odoo.py", line 160, in <module>
main()
File "./odoo.py", line 156, in main
import openerp
File "/home/odoo1/odoo/openerp/__init__.py", line 63, in <module>
import report
File "/home/odoo1/odoo/openerp/report/__init__.py", line 6, in <module>
import interface
File "/home/odoo1/odoo/openerp/report/interface.py", line 13, in <module>
import render
File "/home/odoo1/odoo/openerp/report/render/__init__.py", line 4, in <module>
from simple import simple
File "/home/odoo1/odoo/openerp/report/render/simple.py", line 9, in <module>
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table
File "/usr/lib64/python2.7/site-packages/reportlab/platypus/__init__.py", line 7, in <module>
from reportlab.platypus.flowables import Flowable, Image, Macro, PageBreak, Preformatted, Spacer, XBox, \
File "/usr/lib64/python2.7/site-packages/reportlab/platypus/flowables.py", line 29, in <module>
from reportlab.lib.colors import red, gray, lightgrey
File "/usr/lib64/python2.7/site-packages/reportlab/lib/colors.py", line 17, in <module>
from reportlab.lib.utils import fp_str
ImportError: cannot import name fp_str
What can be the error due to. How to solve this issue?
Regards.
It should be from reportlab.lib.rl_accel import fp_str in the newest version of reportlab.So you need to upgrade the reportlab module.