Trouble connecting Eclipse, tkinter, Swampy and TurtleWorld - python

I am trying to perform Think Python's turtle-related programs in Eclipse but I always seem to have one error bugging me.
It seems like I have installed Eclipse, Python 2.6 and Python 3.3 correctly in my computer, and linked them to Eclipse via Window>>Preferences>>Interpreter - Python >> New Folder in Libraries. I also did this with Swampy215 and 216.
I run with no problems:
import tkinter
import swampy
from swampy import *
BUT, when I run:
import swampy.TurtleWorld
OR
from swampy import TurtleWorld
I get these error messages:
Traceback (most recent call last):
import swampy.TurtleWorld File "C:\Users\mellofr\Downloads\swampy-2.1.6\swampy\TurtleWorld.py", line 8, in <module>
from Tkinter import TOP, BOTTOM, LEFT, RIGHT, END, LAST, NONE, SUNKEN
ImportError: No module named 'Tkinter'
Weirdly, when I type import swampy. Eclipse suggests "TurtleWorld", but seems to ask for Tkinter (Python 2.7) in this process.

Does changing the first line to
import tkinter as Tkinter
help?
See also:
"ImportError: No module named tkinter" when using Pmw

Related

Error message received when trying to import turtle (python 3.9, m1 Mac)

When I try to import the python 3 graphical library, turtle, on my m1 MacBook, I get an error message:
david#Davids-MacBook-Air Python Coding Files % /opt/homebrew/bin/python3 "/Users/david/Desktop/Python Coding Files/hello.py"
Traceback (most recent call last):
File "/Users/david/Desktop/Python Coding Files/hello.py", line 1, in <module>
import turtle
File "/opt/homebrew/Cellar/python#3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/turtle.py", line 107, in <module>
import tkinter as TK
File "/opt/homebrew/Cellar/python#3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
I see it has the library tkinter written in it for some reason. This is weird because on my other Mac, an intel based Mac, with the same python 3 version, and no library such as tkinter install, I didnt get an error message when trying to import turtle
Does anybody know what the problem is?
Python 3's turtle module has always used tkinter. Your other Mac must have tkinter installed. It used to be shipped with Python, but now you need to install it. Assuming you use HomeBrew:
brew install python-tk

When trying to import selenium it does not work

When i attempt to import selenium i get the error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import selenium
ModuleNotFoundError: No module named 'selenium'
My selenium module is currently in:
C:\Users\Maseeek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium
I've seen other people have it in a different directory and want to know how to fix it.
If you are using "PYCHARM" and if you created project with "Virtual Environment" you should choose "Python 3.x.x" instead of "Virtual Environment Python 3.9" that PyCharm created.
If you installed "anaconda" before you need to change paths of libaries.
If you're using PyCharm, then this might help:
PyCharm sometimes shows an error in importing modules that have already been installed (that's annoying). But, try to change the file location to this destination:
C:\Users\Maseeek\PyCharm Projects\(project name)\venv\site-packages\
or try installing the package in PyCharm using python with the following code:
from sys import *
from subprocess import *
call(["-m", "pip", "install", "selenium"])

I can`t import wxpython in anywhere except python console

I installed python 3.8.8 and installed wxpython using pip at terminal
pip install wxpython
and i run simple program
import wx
print(wx.version())
in pycharm and pycharm`s python console, I got
ModuleNotFoundError: No module named 'wx'
in IDLE, I got
Traceback (most recent call last):
File "C:/Users/tasoo/OneDrive/Desktop/wx.py", line 1, in <module>
import wx
File "C:/Users/tasoo/OneDrive/Desktop\wx.py", line 2, in <module>
print(wx.version())
AttributeError: partially initialized module 'wx' has no attribute 'version' (most likely due to a circular import)
in python.exe code works
I want to import wx in pycharm project.
I tried add python in system path but it didn`t work.
You have problem because you saved code in file wx.py and now import wx loads your file wx.py instead of module wx. Rename your file - ie. main.py instead of wx.py
PyCharm may have own Python installed and it may need to install wx in this Python.
Check
import sys
print(sys.executable)
to get full path to Python used by PyCharm and then use this path
/full/path/to/python -m pip install wx
Or search in PyCharm settings (in menu File) and change Python Interpreter.
In PyCharm for every project you may set different Python - if you have installed many versions.

from voice_engine.source import Source ModuleNotFoundError: No module named 'voice_engine'

I am trying to create a program which takes in the direction of arrival of audio using a raspberry pi and Respeaker 4mic array.
I followed the steps on the below link and the installation was successful as shown in the screenshot.
https://pypi.org/project/voice_engine/
screen shot of terminal location
When I run the python program, I get the error:
Traceback (most recent call last):
File "/home/pi/Desktop/doa.txt", line 9, in
from voice_engine.source import Source
ModuleNotFoundError: No module named 'voice_engine'
import sys
import time
from voice_engine.source import Source
from voice_engine.channel_picker import ChannelPicker
from voice_engine.doa_respeaker_4mic_array import DOA
I am using Python 3.7.3 (/usr/bin/python3)
(which is also the default for terminal)
I have tried everything I could think of and googled the error however no answers have helped.

Import pexpect in child module - 'no module named pexpect'

I'm seeing weird behavior that I don't understand, so I'm turning to the experts here on SO for help. I have looked at similar questions, without finding anything that looked helpful.
I'm writing a program that imports two custom modules.
If I run the main program using the cli "./ld_config_automation.py" I get the following error:
laptop$ ./ld_config_automation.py
Traceback (most recent call last):
File "./ld_config_automation.py", line 34, in <module>
from modules.networkcomponent import NetworkComponent
File "/path/to/pprograms/ssh_telnet_automation/modules/networkcomponent.py", line 7, in <module>
import pexpect
ImportError: No module named pexpect
However, if I run the main program using the cli "python ld_config_automation.py" everything works fine and the program runs.
My main program uses the following import statements.
import sys
import getopt
from modules.networkcomponent import NetworkComponent
from modules.recordclass import Record
The module I'm having trouble with "NetworkComponent" uses the following import statements:
import re
import pexpect
Also, if I remove import pexpect from the NetworkComponent module it works as expected without python in front (up to when it has to use pexpect. of course). So it doesn't seem to be a problem with importing modules, as re works ok, just not pexpect.
I'm developing this on mac os X but will implement on CentOS.

Categories

Resources