Error Python PlaySound No module named 'gi' - python

when I request using "playsound" library for Python to play the audio
file .mp3 it returns me the following error:
Code:
import playsound
playsound.playsound("test.mp3")
Error:
Traceback (most recent call last):
File "/home/enzoportela/PycharmProjects/SoftwareRover2018.2/SoftRover/I.A Rover(2018.2).py", line 25, in <module>
playsound.playsound("test.mp3")
File "/home/enzoportela/anaconda3/envs/SoftwareRover2018.2/lib/python3.6 /site-packages/playsound.py", line 91, in _playsoundNix
import gi
ModuleNotFoundError: No module named 'gi'

The most simple way is the vext approach.
pip install vext
pip install vext.gi
Reference:
How do I install python3-gi within virtualenv?

It seems like you are using an anaconda environment. I also faced this issue and fixed it by doing the following:
First, create a symlink to gi module in your system Python. For me, the command is as follows:
ln -s /usr/lib/python3/dist-packages/gi/ /home/USERNAME/miniconda3/lib/python3.7/site-packages/
Then, open the directory:
cd /home/USERNAME/miniconda3/lib/python3.7/site-packages/gi/
and run the following commands:
sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-37m-x86_64-linux-gnu.so
sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-37m-x86_64-linux-gnu.so
My system Python is 3.5 and miniconda Python is 3.7. Your versions may differ from mine, so take care of that in the commands above (-35m- and -37m-).
Method obtained from askubuntu

Related

Python script compiled to .exe giving error: No module named yaml

I can run the code below in Pycharm without issues, but when I create an exe using pyinstaller, I get the following error when I run the executable -
**Traceback (most recent call last):
File "openfile.py", line 1, in <module>
ImportError: No module named yaml
[1296] Failed to execute script openfile**
import yaml
from sys import exit
cfg = yaml.safe_load(open("Config.yml"))
exit()
Note that I'm using Windows 10.
pip install pyyaml will solve this problem
or use virtualenv
pip install virtualenv -p python3 #or python2
virtualenv venv
venv/Scripts/activate
pip install pyyaml

Trouble installing Adafruit's DHT11 Python library

I followed these instructions to install the Adafruit DHT11 library (https://github.com/adafruit/Adafruit_Python_DHT):
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo apt-get install build-essential python-dev
sudo python setup.py install
And I found the library installed under /home/pi (I'm working with a Raspberry Pi 3). The file I want to fun is in /home/pi/Desktop so I move the library into that directory. However, I still can't run my python file properly. This is the error I'm getting:
Traceback (most recent call last):
File "sensorRead.py", line 4, in <module>
import Adafruit_DHT
ImportError: No module named 'Adafruit_DHT'
How do I get rid of this error? And where should I move my file (or the library) so the library will work? Thank you.
I fixed it. I moved my file into Adafruit_Python_DHT/examples and ran it with the python sensorRead.py command. To be honest, I don't know why it works when I put it into examples, but it does.

python script that came with program doesn't seem to find the program module

I just installed Gubbins using their homebrew instructions. Everything seemed to go smoothly and gubbins is now in /usr/local/Cellar/gubbins/1.1.1/bin/gubbins. I'm supposed to be able to use it by running their script run_gubbins.py and giving it an input file. But I get the following error:
>$ /usr/local/Cellar/gubbins/1.1.1/usr/bin/run_gubbins.py test.fasta
Traceback (most recent call last):
File "/usr/local/Cellar/gubbins/1.1.1/usr/bin/run_gubbins.py", line 25, in <module>
from gubbins import common
ImportError: No module named gubbins
Looking inside the run_gubbins.py script I see that the first things it does is
import sys
sys.path.append(".")
import argparse
from gubbins import common
So what might be happening? How come the script within a program package is not recognizing the program it came with? Is there anything I can do to fix this? Thank you so much.
Install homebrew from brew.sh
Open a terminal and enter these commands
curl https://bootstrap.pypa.io/ez_setup.py | python - --user
export PATH=~/Library/Python/2.7/bin:${PATH}
easy_install pip
pip install --user dendropy
pip install --user biopython
pip install --user reportlab
brew tap homebrew/science
brew install http://sanger-pathogens.github.io/gubbins/fastml.rb
brew install http://sanger-pathogens.github.io/gubbins/gubbins.rb

Redhat trying to use pip ImportError: No module named pip

I am trying to use pip on my Redhat system.
I installed pip following the instructions here, but when I try to use it, for example pip install, I get the following error code:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in ?
from pip import main
ImportError: No module named pip
this issue due to common user do not have privilege to access packages py file.
1. root user can run 'pip list'
2. other common user cannot run 'pip list'
[~]$ pip list
Traceback (most recent call last):
File "/usr/bin/pip", line 7, in <module>
from pip._internal import main
ImportError: No module named pip._internal
solution :
root user login and run
chmod -R 755 /usr/lib/python2.7
fix this issue.
If pip is already installed and your unable to access it, one of the reason could be that you don't have permissions to read or execute the library. Try doing
sudo chmod -R u+rx /usr/lib/python2.7/site-packages/pip/
If pip is installed in a different folder, you can obtain the folder path by doing
>>> import pip
>>> pip.__path__
['/usr/lib/python2.7/site-packages/pip']
If you don't have root rights and running on python 2.6 then you can try this file https://bootstrap.pypa.io/2.6/get-pip.py (it is from same instruction you used, it is a simple python script which installs all dependencies and pip itself) and run it with command python get-pip.py --user

python module for libnet in Opensuse

I have tried to run an Python program in my Opensuse OS this Program used libnet and pcap.
import queue
import sys
import socket
import libnet
from libnet.constants import *
import pcap
I have installed libnet-devel but when i run the program i recieve the folowing message.
Traceback (most recent call last):
File "example.py", line 9, in <module>
import libnet
ImportError: No module named libnet
I have tried with different Python version, How can i solve this Problem?
using the system python (the one in /usr/bin/python):
make sure that python-pip is installed via yast
download pylibnet from http://sourceforge.net/projects/pylibnet/
install pylibnet with the command
sudo pip install ./pylibnet-3.0-beta-rc1.tar.gz
there does not seem to be a version of pylibnet packaged and available through yast, which is why you need to install one using pip (which is a program for installing python packages).
libnet-devel only installs the c library - the above installs the python library.
[edit: forgot the "install" in the pip command; added download instructions]

Categories

Resources