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.
Related
import glob
import os
from contextlib import closing
from videosequence import VideoSequence
from PIL import Image
import face_recognition
import subprocess
from pytube import YouTube
When I run my project in a venv in Pycharm, this error message shows up
C:/Users/usr/PycharmProjects/project/main.py
Traceback (most recent call last):
File "C:\Users\usr\PycharmProjects\project\main.py", line 4, in <module>
from videosequence import VideoSequence
File "C:\Users\usr\PycharmProjects\project\venv\lib\site-packages\videosequence\__init__.py", line 9, in <module>
import gi
ModuleNotFoundError: No module named 'gi'
From the VideoSequence GitHub page:
The implementation is based on GStreamer and so de facto only works on a modern Unix-alike such as Linux or FreeBSD.
The PyGObject introspection libraries must be installed. (See below.)
You seem to be working on Windows (I do not know whether VideoSequence does in fact work on Windows), and, crucially, it is clear PyGObject is not installed.
Hello Programmers of Stack overflow,
I am trying to import I library for my code, but whenever I execute my code on PyCharm, i get an error:
File "C:\Users\USER\projectextinguish\venv\lib\site-packages\command_runner\elevate.py", line 49, in <module>
raise ImportError(
ImportError: Cannot import ctypes for checking admin privileges on Windows plaform
Does anyone know how i can import ctypes?
I have no idea what to do.
code:
import os #self explainitory
from command_runner.elevate import elevate
def admin():
elevate(mainfirewall)
admin() # executes admin function
def mainfirewall ():
os.system("netsh advfirewall set allprofiles state off") # disables firewall
mainfirewall() #executes firewall function
I could reproduce the last part of your error message by installing command_runner and not installing pywin32. I got:
Traceback (most recent call last):
File "C:\Users\...\ess\venv\lib\site-packages\command_runner\elevate.py", line 43, in <module>
import win32event # monitor process
ModuleNotFoundError: No module named 'win32event'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\...\ess\venv\lib\site-packages\command_runner\elevate.py", line 49, in <module>
raise ImportError(
ImportError: Cannot import ctypes for checking admin privileges on Windows platform.
The first part of the stacktrace gives the cause: the pywin32 package is required to have the win32event module.
How to fix: install the missing package with pip install pywin32
import sys
if sys.version_info[0] < 3:
import Tkinter as tk ## Python 2.x
print("Python 2.X")
else:
import tkinter as tk ## Python 3.x
print("Python 3.X")
print("version", tk.TclVersion)
If I run from shell with python I get:
$ python test_tk
Python 2.X
('version', 8.6)
If I run from shell with python3 I get:
$ python3 test_tk
Python 3.X
version 8.6
But in PyCharm I get ImportError
Traceback (most recent call last):
File "/home/myuser/PycharmProjects/Project/file.py", line 12, in <module>
import tkinter as tk
File "/usr/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
Process finished with exit code 1
I looked in PyCharm File>Default Settings>Project Interpreter>+ and it doesnt find any tkinter module...
I tried changing environment and in python 2.x I get:
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
From all the articles I read my conclusion would be that this is a path issue.
How can I resolve this?
I am new to python and using this tutorial http://code.tutsplus.com/tutorials/how-to-build-a-python-bot-that-can-play-web-games--active-11117 to build a bot which plays games.
I copy-pasted the file and installed the libraries .When i tried running the file in the terminal on my mac i got this error :
Traceback (most recent call last):
File "bot.py", line 2, in <module>
import Image, ImageGrab, ImageOps
File "/Library/Python/2.7/site-packages/PIL/ImageGrab.py", line 34, in <module>
import _grabscreen
ImportError: No module named _grabscreen
Here is the complete code
import os, sys
import Image, ImageGrab, ImageOps
import time, random
from random import randrange
import win32api, win32con
from numpy import *
I think you should pay attention to the these words in the tutorial, 'Some of the code and libraries are Windows-specific. There may be Mac or Linux equivalents, but we won't be covering them in this tutorial.'.
And current version of ImageGrag only works for windows.
>>> from Tkinter import tkMessageBox
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from Tkinter import tkMessageBox
ImportError: cannot import name tkMessageBox
I am getting this error, even though from Tkinter import * is working fine. I am using Python 2.7.5.
tkMessageBox is a module on its own, so you should import it separately:
import Tkinter
import tkMessageBox