I'm using Pycharm on Windows 10.
Python version: 3.8.6
I've checked using the CMD if I have tkinter install python -m tkinter. It says I have version 8.6
Tried:
import tkinter.
I get "No module named 'tkinter' "
from tkinter import *.
I get "Unresolved reference 'tkinter'"
Installed future package but that didn't seem to change the errors.
Any suggestions on how to fix this issue?
Thank you!
You just verify in the project settings, sometimes Pycharm doesn't use the same interpreter.
You can try "pip install tkinter" in cmd
Related
I'm having a problem with PIL where vs code says there is no module named PIL when there is. If I run the file without vs code the module imports fine. In the vs code problem tab it says this:
import PIL could not be resolved from source. Pylance(reportmissingmodulesource)
I know the library is installed because if I do pip install pillow, it says requirement already satisfied.
Things I've tried to fix it: reinstalling python, uninstalling and reinstalling pillow, upgrading pip, installing the PIL library(pip install Pillow-PIL).
None of these things worked so I am out of ideas for things to try. Could someone help me with this?
This part is important:
If I run the file without vs code the module imports fine
If something like this happens, then you are not running the same python interpreter, because modules are always installed to specific installations of python that you have.
Do the following:
Add to your script the first two lines
import sys
print(sys.executable)
This will print the path to the python executable that is interpreting that script. If you now run this script with and without vs code, it should print two different python paths. Now you can install to the python interpreter that is being used by vs code specifically by typing
/path/to/python/used/by/vs/code/python -m pip install pillow
in case someone stil has this problem on Mac or it didn't work, I used the code "python3 -m pip install pillow" in my vs code in terminal below but I had different code "from PIL import ImageTk,Image"
If anyone stumbles upon this problem and can't figure out what's wrong:
the first thing to do is simply restarting the Visual Studio Code instance.
That worked for me after running pip3 install Pillow from the VSCode terminal.
How about this?
pip install Pillow
For reference: https://pypi.org/project/Pillow/
So pygame is definitely on my computer, and I can call it through the Python terminal that was installed when I downloaded Python 3.8. However, I can't get Spyder to import the pygame module. When I do, it gives me this error message:
ModuleNotFoundError: No module named 'pygame'
Could someone please walk me through how I set up pygame so that Spyder can recognize the pygame module? Thanks!
You've only installed pygame into a different python editor. If you want it to work on spyder, you should install it via the pip that belongs to spyder.
I am running RedHat 4.1.2 offline and trying to get _tkinter working for Python 2.7.13. I have Tcl/tk 8.4 installed, but it doesn't seem to be working right. libtcl8.4.so is located in /usr/lib64/ and I'm not sure if that's related, but I figured I would mention it. Here is the error when I try import Tkinter.
Python terminal output
Perhaps you could try a package manager such as Anaconda and install Tkinter.
This post may help.
I installed PyDev in Eclipse to run Python programs, but I’m facing trouble importing simplegui. It is showing me this error:
import simplegui
ImportError: No module named simplegui
My installed PyDev version is 2.7.1.
You can use SimpleGUICS2Pygame.
Just change
import simplegui
by
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
in your CodeSkulptor program and run it in standard Python
Did you learn Python using CodeSkulptor?
simplegui is a custom module for CodeSkulptor, meaning that it is only available in CodeSkulptor.
More information here.
I am using a Mac, when I installed simplegui off of the Python website, I had to import it as:
import simpleguitk
I also downloaded it through terminal with the command:
sudo pip install SimpleGUITk
Simple, download simplegui.zip form http://florian-berger.de/en/software/simplegui.
unzip simplegui-x.x.x.zip
cd simplegui-x.x.x
python setup.py install
Replace x.x.x with version number. You might want to run the last step with sudo rights.
I have an existing Python 2.4 and it is working properly with tkinter as I tested it using
python
import _tkinter
import Tkinter
Tkinter._test()
Now, I have installed python 2.5.2 but when I try the same tests (with the newer version), it returns (but the same tests are working for the previous version)
ImportError: No module named _tkinter
I know that tcl8.5 and tk8.5 are installed on my machine as the following commands return there locations
whereis tcl
tcl: /usr/lib/tcl8.4 /usr/local/lib/tcl8.5 /usr/local/lib/tcl8.4 /usr/share/tcl8.4
whereis tk
tk: /usr/lib/tk8.4 /usr/local/lib/tk8.5 /usr/share/tk8.4
Any ideas how do I make my newer python version work with tkinter?
The files you found are for linking directly to tcl/tk. Python depends on another library as well: _tkinter.so. It should be in /usr/lib/python2.5/lib-dynload/_tkinter.so.
How did you install python2.5? If you are using Debian or Ubuntu you need to install the python-tk package to get Tkinter support.
If the _tkinter.so file is there, your environment could be causing problems.
If
python -E -c "import
Tkinter;Tkinter._test()"
suceeds, but
python -c "import
Tkinter;Tkinter._test()"
fails, then the problem is with how your environment is set up. Check the value of PYTHONPATH is set correctly.