ModuleNotFound Import Turtle Dilemma - python

I'm new to python and programming in general, and I wanted to play around with the turtle module, but when I try to import it (I was told it was part of the python library so I did not need to download it) I get an error telling me that there was no module.
The specific error I get in Visual Studio Code is:
File "turtle.py", line 107, in
ModuleNotFoundError: No module named 'tkinter'
I have tried import turtle, from turtle import * and my python file is not named anything related to the turtle module.

Related

Attribute Error module 'turtle' has no attribute 'Turtle'

This problem occurred to me quite recently. I have no idea what i am doing wrong due to me being a beginner in python. If anyone is interested I am using a Raspberry pi 400 and I am using VSC but anyways here is my code:
import turtle
import random
pat=turtle.Turtle()
colours=["orange","blue","red","yellow", "cyan"]
turtle.Screen().bgcolor("black")
for i in range(200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000):
for i in range(2):
pat.forward(300)
pat.right(100)
pat.right(100)
pat.forward(300)
pat.right(100)
pat.left(5)
pat.color(random.choice(colours))
Could it be that you have a file named turtle.py in the same folder, or in any other folder contained in the PYTHONPATH environment variable? In that case import turtle might not load the turtle package, but instead the local Python file, which does not contain an executable object named Turtle and hence the AttributeError is raised when calling turtle.Turtle().

error importing module you created (Python)

I created module that have tree functions and when I am trying to import that module I have red line under the module name and the error says "No module named data" and the file is in the same path as the file I am trying to import to. but the functions are working but it's causing bugs in my program,
Someone know how do I fix that problem?.

ImportError: No module named blahblah, but it's in the working directory

I'm not a Python programmer, so I assume this is a rookie question.
I'm importing a cython file into a script in python (the file extension of the cython file is pyx if that makes a difference). I do so using this;
from im2col_cython import col2im_cython, im2col_cython
Here is the error I get;
from im2col_cython import col2im_cython, im2col_cython
ImportError: No module named im2col_cython
The file is in the same folder as the script that it is imported in, I have also set the working directory to that folder (just incase there was some issue with that). I'm using Anaconda, Python 2.7, Windows 7.
I've been trying to fix this for around 4 hours, it seems like a simple error but this is my first real foray into Python.

tkinter - "ImportError: the specified module could not be found" python 3.5.1

I'm having issues running a tkinter program in python 3.5.1, and I really don't understand what's going on. It's never been a problem prior to this point, but now when attempting to run the program in question, I get the following error:
Traceback (most recent call last):
File "C:/Users/Joe/PycharmProjects/Physics2-0/Physics2-0.py", line 1, in <module>
from tkinter import *
File "C:\Python35\lib\tkinter\__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: DLL load failed: The specified module could not be found.
I recently uninstalled and reinstalled python 3.5.1 to make sure that everything was set back to the default way it's supposed to be and was when I started developing the program, because I thought I might have messed something up while trying to work with cx_freeze, and as far as I can tell, everything is as it was before, when the program worked. I have no idea what changed. The import statements for the program in question are below:
from tkinter import *
from tkinter import ttk
from sympy import Symbol
from sympy.solvers import solve
Any and all help is appreciated. I'm at a loss for how to go forward.
EDIT 1: This is getting weirder and weirder. After running the tkinter test like I said in the comments that I did, I tried running the program, and now it will run. I have no clue why.
EDIT 2: The plot thickens. I created a setup.py for cx_freeze to make another attempt at creating an executable of the program. I set my tcl and tk libraries manually as c:\python35\tcl\tcl8.6 and c:\python35\tcl\tk8.6, respectively, and tried to build the executable. It seemed like it worked, but when I ran the executable, it gave me the same error message as it did above, but in a popup error message box, not console. I then tried to do the tkinter test in a python console again, and now when I try import _tkinter I get an error message saying ImportError: DLL load failed: The specified module could not be found. I don't think my computer has ever confused me this much. Someone please help.

Use Tkinter in Abaqus 6.12-1 import error

Getting a simple file dialog in abaqus seems pretty difficult, so i wanted to use tkinter. It seems tkinter come with abaqus, but when i try to import the module it says:
File "/opt/Abaqus/6.12-1/tools/SMApy/lib/python2.6/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
importing _tkinter is also not working. so how can one get tkinter to work in abaqus?
Greetings,

Categories

Resources