I have recently changed my text editor from IDLE to Atom but when I started to run my program that i have ran in the past eg(music player using pygame) it didn't work and came up with this error message:
Traceback (most recent call last):
File "/Users/jacquelinethompson/Desktop/Untitled.py", line 1, in <module>
import pygame
ImportError: No module named pygame
[Finished in 0.088s]
I checked the import to see if it worked in IDLE and it works fine there. Can anyone explain why and how to fix it.
I am on the MacOS and am using python3.6
Related
Not sure if this is a VS code or Jupyter problem but I have been using Jupyter in VS Code (specifically using the "# %%" implementation outlined here).
I noticed recently that my error tracebacks are not showing the full traceback, but rather only the first layer.
For example, I made a simple dummy error (hiding my path on purpose here):
ran in interactive mode:
NameError
Traceback (most recent call last)
[PATH] in <module>
----> 97 py_getAnnotation(["a", "b"])
[PATH] in py_getAnnotation(experiments)
NameError: name 'hold_s' is not defined
But running script normally:
Traceback (most recent call last):
File [PATH], line 97, in <module>
py_getAnnotation(["a", "b"])
File [PATH], line 77, in py_getAnnotation
hold_s.name = col
NameError: name 'hold_s' is not defined
I recently had to switch from Mac to Windows. So I am not sure if this is a VS Code thing, an iPython setting/version thing, or maybe even an OS-specific thing.
I've never had this happen before. Any ideas would be appreciated.
NOTE:
I tried uninstalling ipython dependencies and reinstalling.
I have tried running %xmode as suggested in an old post
Edit: I have also copied and pasted my code into a jupyter notebook at that error traceback is fine. So seems to be VS Code Specific.
Edit: Downgrading VS Code to an earlier version worked! But if anyone has an idea why it happened in the first place that would be appreciated.
I'm trying to open an Excel file using Pycharm, but always get a the following message:
Traceback (most recent call last):
File "C:/Users/.../PycharmProjects/Excelmodules/openxlsx.py", line 2, in <module>
from openpyxl import openpyxl
ImportError: cannot import name 'openpyxl' from 'openpyxl' (C:\Users\...\PycharmProjects\Excelmodules\venv\lib\site-packages\openpyxl\__init__.py)`
Process finished with exit code 1
I have successfully installed Openpyxl in Pycharm (using another thread on stackoverflow) and have checked the file name/path is correct, but still get the error message.
I am new to python so it might be something I have/haven't done, but the only things I can think are causing this are:
running it through Pycharm rather than command prompt
Windows 10 did a forced update and created an "old windows folder and I'm wondering whether Pycharm or openpyxl are trying use/run using the old.windows folder
the Excel file needs to be in the Pycharm folder
I was starting a project in Automate the Boring stuff, but can't get past this step.
Please help!
Thank you
Rob
Henlo everyone,
I met a very specific problem with my Python installation. I have a PyCharm project using a venv with pywikibot installed. Whenever I try to import the module, I get the following error:
Traceback (most recent call last):
File "C:/Users/<username>/<path to project>/alphabets/coptic_characters.py", line 1, in <module>
import pywikibot as pwb
File "C:\Users\<username>\<path to project>\venv\lib\site-packages\pywikibot\__init__.py", line 15, in <module>
from decimal import Decimal
File "C:\Users\<username>\Anaconda3\lib\decimal.py", line 3, in <module>
from _decimal import *
AttributeError: module 'numbers' has no attribute 'Number'
It appears to have broken itself because earlier in the day it worked with no problems.
I also have the module installed on a global Anaconda3 setup elsewhere in my computer. It works fine everywhere except, that's where it gets weird, when I try to execute it inside the project directory. It gets even stranger than that, if I execute the interpreter in a sub-folder, it works again. I don't understand what's happening here at all…
I tried creating a new project but I get the same error and behavior.
What am I missing? I don't understand why it stopped working suddenly event though I did nothing to the venv.
P.S.: I'm on Windows 10.
So !
It appears that a module I created with the name numbers was interfering with Python's code. I just changed the name and it suddenly worked again !
Thanks to #furas for suggesting this.
Whenever I run my code in the IDLE's shell, it always comes out with this error:
Traceback (most recent call last):
File "C:\Users\dELL\Desktop\MyProject\ReactionTimeProgram.py", line 2, in <module>
import pygame
ImportError: No module named pygame
Is it telling me I haven't installed Pygame, because I have.
How can I fix this error?
Best Regards
RMR :)
Are you running the proper version of python? When I run pygame with python2 instead of python3, that's what happens for me.
1) I am getting error on the python script if i run it through sublimetext. How do i map my existing python to sublime text rather than using the one comes with sublimetext ?
import Tkinter as tk
import tkinter
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named tkinter
i think the tool use its own python.
2) is there a short key like (the common F5) to run the script on sublimetext ?
Please suggest.
Thank you
The Python builder in Sublime Text runs the active Python file with the Python executable found in your PATH. You can start it with Tools -> Build (Ctrl + B).