python3 "ModuleNotFoundError: No module named 'OpenGL'" - python-3.x

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.

Related

Error trying to import cv2(opencv-python) package

I am trying to access my webcam with cv2(opencv-python) package.
When I try to import it I get this error:
Traceback (most recent call last):
File "server.py", line 6, in <module>
import cv2
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 5, in <module>
from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Note: I am trying to import this package on putty, on Linode server - that might be useful information.
If anyone can explain to me what is happening and maybe solve the problem I will highly appreciate it!
Install opencv-python-headless instead of opencv-python. Server (headless) environments do not have GUI packages installed which is why you are seeing the error. opencv-python depends on Qt which in turn depends on X11 related libraries.
Other alternative is to run sudo apt-get install -y libgl1-mesa-dev which will provide the missing libGL.so.1 if you want to use opencv-python. The libgl1-mesa-dev package might be named differently depending on your GNU/Linux distribution.
Full installation guide for opencv-python can be found from the package documentation: https://github.com/skvark/opencv-python#installation-and-usage
this worked for me:
conda install -c fastai opencv-python-headless

Rpy2 import rpy2.robjects as robjects fails

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

No module named 'info' on fresh Python 3 installation

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...

AttributeError: module 'theano' has no attribute 'tests'

I am trying to use theano gpu on my ubuntu, but each time after it running one time successfully, it will give me the error like this when I try to run next time. No idea why, could anyone help me ?
import theano
Traceback (most recent call last):
File "", line 1, in
File "/home/sirius/anaconda3/lib/python3.5/site-packages/theano/init.py", line 95, in
if hasattr(theano.tests, "TheanoNoseTester"):
AttributeError: module 'theano' has no attribute 'tests'
I met the same problem.I just fix it with conda install nose
For latest version of Theano (1.04)
import theano generates an error without the nose package installed
install via conda or pip pip install nose / conda install nose

pip isn't working when importing something

To install pymongo for pypy3 2.1 Beta 1, I installed pip using the following commands:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
./pypy ez_setup.py --user
where pypy is the executable of pypy3 2.1 Beta 1. After that, pip and pip-3.2 will come to the current directory. But when running pip or pip-3.2, I get the error:
Traceback (most recent call first):
File "pip-3.2", line 5, in <module>
from pkg_resources import load_entry_point
zipimport.ZipImportError: pip==1.4.1
It seems that the problem comes from from pkg_resources import load_entry_point of the pip/pip-3.2. But this statement runs OK when I put it in pypy or python3 IDLE. What's the matter? How to solve this problem and proceed to install pymongo for pypy3 2.1 Beta 1? Thank you.
PS: I'm using Ubuntu. python3 is installed in the system. If u need any other information pertaining to solving the question, please comment.

Resources