I'm following a pygame tutorial, and in it, you need to use multiple different modules. I was able to download all of them, except this one called Vec2D. When I try to run it in command prompt, it gives me this:
This is really weird because it gives no output - the module isn't set up and I don't get an error. When I try to test it later, it doesn't work. Does anyone know how to help me?
The instructor has written his own module, called vec2d_jdm.py containing a class called Vec2D.
You don't need to install it, just make sure that the file vec2d_jdm.py is in the same folder as the code you're running and from vec2d_jdm import Vec2D at the top of your code where you import everything else (such as pygame I imagine).
Related
I'm trying to use pygame for the first time by following a tutorial on Youtube.
I realized that Pylint points out a lot of errors that I think are irrelevent, such as "C0114:missing-module-docstring". Is there a way to "customize" what Pylint displays ? I find myself with a lot of blue underlining in my whole code which is unpleasant, and I don't want to uninstall Pylint because it can be handy when I make a typo, for example.
There is also an error that I don't understand : "E0611:no-name-in-module". This is shown at the beginning of my code when I try to import a module from pygame :
from pygame.math import Vector2
This is strange because my game runs using this module without any problems. It also occurs when I call functions from pygame such as :
pygame.init()
Again, it works, but it's underlined in red and shows an error. Is there any way to fix this ?
I tried to go in the settings to see if I could modify something regarding Pylint errors, with no success.
You can control what checks pylint does with a separate .pylintrc configuration file, just add one to your project root and pylint should use it automatically. You can create one for yourself from scratch, use the builtin generator with pylint --generate-rcfile or try finding a ready template on the web such as:
https://www.codeac.io/documentation/pylint-configuration.html
https://gist.github.com/rpunkfu/3cd6f8b8b23e27adedbd
I have a simple user interface with tkinter that works perfectly fine. However, when I import another python module, whenever I use the button that calls this specific line of code (the second one):
from tkinter.filedialog import *
files = askopenfilenames()
(which works fine normally and even gets the files etc...) Jupyter notebook crashes without any error message, making it hard to understand what the problem is. After investigating, I discovered that this error happens because in the other module that I import in this interface file, there is this import:
from sklearn.cluster import KMeans
When I comment out this import in the other module and try again, the button event works fine and allows me to select files. However, when I uncomment that import line again, the same problem happen.
Since there is no error message, it is hard to understand the problem and I searched but couldn't find any known problem between KMeans and this Tkinter function. Any help would be really appreciated.
Due to the lack of error message, it was impossible to find the exact cause of the problem. Suspecting a conflict in libraries, I created a new environment and installed libraries again. If anyone faces a similar issue, I suggest using conda to install libraries instead of pip as much as possible, and only use pip when no other choice is present.
The problem is that, when I try to import a certain class from a .py archive that is in the same package it gives me an error. I have tried using from .something import function, from something import function and both ways end in error.
So your question is kinda vague but ive had a similar issue from what I understand in sublime text
to solve this make sure you have the correct python interpreter on visual studio
I know that this question has already been asked. But answers below these questions doesn't fix my problem. Here it is:
When I download some code from GitHub, it's always divided into separate files. I understand that it's important to have organized code, which is why I'd like to do the same.
However, whenever I try importing a function from a file, I always seem to get a ModuleNotFoundError error.
The file that I'm trying to import is in the same directory as the file importing the code. This also doesn't work with other code, for example, when I download code from GitHub that organizes code using separate files, it still returns the same error.
I've tried two different python installations (anaconda 3.7.3 and py 3.7.0), but still not luck. FYI I use pzyo to run my files.
Here's an example of how I import another file:
from fun import f
I have tried this as well:
import os
os.chdir("C:/Users/amau4/Desktop/test")
from fon import f
How would I go about fixing this? Thanks in advance!
I have a Tkinter program that i use for time management. I decided to have it scan my inbox in outlook to check emails for tags, and then based on the tag, add it to my list of tasks to do for the night.
The code i wrote works just fine, but i'm getting an error when I import win32com.client. I can import it in IDLE, but it is having problems importing when i try to run the code with a .bat file, or double clicking the .py file.
I have found several people with similar problems, but from what i can tell, it's having problems with win32api module, or pywin32
Traceback (most recent call last):
File "my_program_filename.py", line 1, in <module>
import win32com.client
File "c:/Python27/lib/site-packages/win32com/__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: DLL load failed: The specified module could not be found
I'm really confused. When i get the sys.path it's the same with IDLE as it is running from the .py file with the exception of an added "c:/users/username/desktop/timer" for my .py file.
I'm really lost and haven't had to mess with the system path, but I'm not able to figure out what i need to do to fix this.
What do I need to do to get pywin32 working so I can use win32com.client?
Any help is greatly appreciated. Thanks!
IIRC, the problem was attempting to link to the debug build. I think i had to dupe the release build and rename it to be debug or something.
try building release and see if it "just works". if so, you have a direction to explore
this is an issue of not having the correct paths in the sys.path. If you make sure that all of the pywin32 folders are in the sys.path(If you check in IDLE it can show that the folders are included even when they aren't?!?!?).
You also have to make sure you run your code from inside your Python directory or it will fail to import win32api. I also found that if you do anything in a function that uses pywin32 and you accidentally misspell the function when you call it, the whole import fails without telling you your function is misspelled. You can also navigate to the /Python27/Lib/site-packages/win32com/client folder and run makepy.py to make sure the right Object library is installed.
When you run makepy.py, you select the COM object you want to use and it creates packages specific to what you want to use. I don't fully understand why this is, but once i did this and ran my file from the Python folder it worked! There is a more in depth explanation on how to get this working right here.
I found this link to be the solution rather than the win32com/client as indicated above: win32com import error python 3.4
in my case typing in cmd:
python C:\Python27\Scripts\pywin32_postinstall.py -install
I hope this helps