I´ve installed and uninstalled pygame several times, I tried with pip/pip3 and still appears the following error:
Traceback (most recent call last):
File "c:\Users\josel\Desktop\Programación\Python\pygame\test\main.py", line 3, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
I also executed "pip install pygame" in the vsc terminal and gave this message:
Requirement already satisfied: pygame in c:\users\josel\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (2.0.1)
Edit:
The output of
import sys
print(sys.path)
is:
['c:\\Users\\josel\\Desktop\\Programación\\Python\\pygame\\test', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\DLLs', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39', 'C:\\Users\\josel\\AppData\\Roaming\\Python\\Python39\\site-packages', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\win32', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\win32\\lib', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\Pythonwin']
A short way to fix this is using a venv
python3 -m venv venv
source ven/bin/activate
pip install pygame
keep the venv activated when you run the code
use
which python # check if VSC is using the right interpreter
Related
Hi I generated a pyc with python -m compileall file.py
The program works in Pycharm and pandas is installed in venv but when I launch the pyc without the venv interpretor or on another machine it says Module not Found.
Panda module is found when I install pandas outside the venv.
Do I have to do pip install all modules on every environment or is there a way for the .pyc to work without installing modules on the host ?
project
$ python PXAGIRA01.cpython-37.pyc
Traceback (most recent call last):
File "_SOURCES/PXAGIRA01.py", line 4, in
ModuleNotFoundError: No module named 'pandas'
I'm trying to turn my python project into .exe
I used : pyinstaller --onefile main.py
Then I moved the main.exe into the original file to be sure it can access all the dependencies.
When I run the main.exe, I get an error, failed to execute script main.
I typed cmd in the directory of the python project, and tried python main.py
It gave me this error :
Traceback (most recent call last):
File "main.py", line 3, in <module>
from PyQt5 import QtWidgets, QtCore
ModuleNotFoundError: No module named 'PyQt5'
Even though every module are installed, why is it telling me that?
Thank you.
You haven't installed pyqt5.
Try pip install pyqt5 or pip3 install pyqt5
for linux
sudo apt install python3-pyqt5
I've installed rpy2 through pip install rpy2. After this in a Jupyter notebook the import works fine:
import rpy2
print(rpy2.__version__)
which returns 3.1.0.
However when I type this import rpy2.robjects as robjects, I get the following error:
ValueError: The system "%s" is not supported.
Does someone know where this error comes from and how to solve it?
I had exactly the same problem.
I uninstalled the package and reinstalled it with conda (as I use Jupyter notebook through Anaconda):
conda install rpy2
Doing this it worked just fine.
The version installed was 2.9.4. There may be an issue with the version 3.1.0 I believe.
I have a similar problem. I had previously installed rpy2 2.9.5 withpip3 install rpy2 and it worked fine. However, today I tried updating it with pip3 install --upgrade rpy2 and got the following error:
Collecting rpy2
Using cached https://files.pythonhosted.org/packages/62/bc/d43df0d9e96a38985a97d1cbdb5722e10cd8fa0da45686972f0b8fd18a67/rpy2-3.2.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-irk23ljv/rpy2/setup.py", line 21, in <module>
from rpy2 import situation
File "/tmp/pip-build-irk23ljv/rpy2/rpy2/situation.py", line 98
raise ValueError(f'The system {system} is currently not supported.')
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-irk23ljv/rpy2/
I can't just stick to the older version because what I'm actually trying to do is to install another Python package that has rpy2 listed as a dependency. The install fails with the same error message.
Any update on the subject?
Edit
It looks like this might be a compatibility issue with Python 3.5 -- see https://bitbucket.org/rpy2/rpy2/issues/580/installing-rpy2-on-travis-with-pip. I've just opened an issue here: https://github.com/rpy2/rpy2/issues/356
I am running python3. I've installed OpenGL (pip install OpenGL PyOpenGL_accelerate). When I run my program (python3 opengltest1.py) I get this error:
Traceback (most recent call last):
File "opengltest1.py", line 4, in <module>
from OpenGL.GL import *
The solution was to install OpenGL with pip3 instead of pip, i.e.
pip3 install pyopengl
#eyllanesc Thanks for the help. In following up on your suggestion, I found the solution.
This worked for me! You must download every package with pip3. All things are separated because the syntax is different from Python 2 to Python 3.
I did a fresh python3 installation on OSX via homebrew:
brew install python3
Then I created a virtual environment for my project and installed scipy and scikits.samplerate:
virtualenv -p /usr/local/bin/python3 pythen_env
pip install scipy
pip install scikits.samplerate
However, when I try to import a function from scikits.samplerate, I get the following error:
>>> from scikits.samplerate import resample
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/my/project/path/pythen_env/lib/python3.6/site-packages/scikits/samplerate/__init__.py", line 4, in <module>
from info import __doc__
ModuleNotFoundError: No module named 'info'
Info happens to be the first module from the package itself that is imported in __init__.py.
Strangely, the module info.py exists in /my/project/path/pythen_env/lib/python3.6/site-packages/scikits/samplerate/:
ls /my/project/path/pythen_env/lib/python3.6/site-packages/scikits/samplerate/
__init__.py setup.py tests __pycache__
info.py setuphelp.py version.py
The error also happens when I try the same without virtualenv, as well as for other packages. How could I start to debug this issue?
The problem seems to be that the package scikits.samplerate does not support Python 3.X (see issue). However, there is a fork which supports Python 3.X. You can install it via
$ pip install git+https://github.com/gregorias/samplerate.git
As always: people can make anything they like in repositories. I did not check which changes gregorias made.
the git version does support py3
https://github.com/cournape/samplerate
(merged the PR from #gregorias)
I should find the time and procedure to update pypi too...