Error with installing and importing gTTS in Python - python

I'm facing this issue whenever I am installing and importing gTTS.
Issue in installing:
ERROR: Could not install packages due to an OSError: [WinError 2] The system cannot find the file specified: 'C:\\Python310\\Scripts\\gtts-cli.exe' -> 'C:\\Python310\\Scripts\\gtts-cli.exe.deleteme'
Issue in importing:
Traceback (most recent call last):
File "C:/Users/User/Desktop/check.py", line 1, in <module>
from gtts import gTTS
ModuleNotFoundError: No module named 'gtts'
I did pip install gtts
and imported from gtts import gTTS.
Thank you!
PS: Python version : 3.10.0

How to install gTTS in Python.
There can be problems caused in installation and usage because of Admin access. The solution is to install gTTS using :
pip install -U gtts
Reference: https://github.com/pypa/pip/issues/9023#issuecomment-713171229

Related

PyAudio M1 Mac issue

I have been suffering to install PyAudio in my M1 Macbook Pro lately. But I finally able to install it. First I installed portaudio using this command: brew install portaudio.
Then I successfully installed PyAudio using this command:
pip install --global-option='build_ext' --global-option='-
I/opt/homebrew/Cellar/portaudio/19.7.0/include' --global-option='-
L/opt/homebrew/Cellar/portaudio/19.7.0/lib' pyaudio
I also checked the directory so that there's no mistake. But whenever I test PyAudio by importing it, it gives me this error:
Could not import the PyAudio C module '_portaudio'. Traceback (most recent call last): File "/Users/arannya/Documents/Python Projects/VASS/main.py", line 1, in <module> import pyaudio File "/Users/arannya/Documents/Python Projects/VASS/venv/lib/python3.9/site-packages/pyaudio.py", line 116, in <module> import _portaudio as pa ImportError: dlopen(/Users/arannya/Documents/Python Projects/VASS/venv/lib/python3.9/site-packages/_portaudio.cpython-39-darwin.so, 2): Symbol not found: _PaMacCore_SetupChannelMap Referenced from: /Users/arannya/Documents/Python Projects/VASS/venv/lib/python3.9/site-packages/_portaudio.cpython-39-darwin.so Expected in: flat namespace in /Users/arannya/Documents/Python Projects/VASS/venv/lib/python3.9/site-packages/_portaudio.cpython-39-darwin.so
Please help me. Thanks in advance.

ffpyplayer ImportError: DLL load faileld while importing player

I'm working on Windows 10, using python3.8. I wanted to install the ffpyplayer module, and did so using the command:
python3 -m pip install --upgrade ffpyplayer
There seemed to be no issues. Using python in PowerShell and stating import ffpyplayer doesn't return anything, however, when I try and run `from ffpyplayer.player import MediaPlayer. It returns the following error
from ffpyplayer.player import MediaPlayer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"C:\Users\g\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\ffpyplayer\player\__init__.py", line 10, in <module>
from ffpyplayer.player.player import MediaPlayer
ImportError: DLL load failed while importing player: The specified module could not be found.
Why is it able to import in one instance and not the next? What is causing the import error in the second example?
ffpyplayer builds ffmpeg include path as follows:
_ffmpeg = join(sys.prefix, 'share', 'ffpyplayer', 'ffmpeg', 'bin')
sys.prefix resolves to Python installation directory, e.g. C:\Program Files\Python.
If ffpyplayer is installed using PIP not in CMD administrator mode, the package is installed into user local %AppData%\Python directory. This is the reason ffmpeg does not get resolved as expected.
Solution:
pip uninstall ffpyplayer
CMD (Administrator mode)
pip install ffpyplayer
I answered a similar question, but basically import ffpyplayer in your specfile and add ffpyplayer.dep_bins to your tree like so:
*[Tree(p) for p in (source1 + source2 + ffpyplayer.dep_bins)]
https://stackoverflow.com/a/70392062/16355112

Importing a module throws ModuleNotFoundError even after module is installed

I'm trying to install pyperclip on Python 3.8.6 on Windows 10, and after typing
pip3 install pyperclip
in cmd it tells me that pyperclip has been successfully installed, but when I then try import pyperclip on they Python shell I get the following error message:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pyperclip
ModuleNotFoundError: No module named 'pyperclip'
I've tried uninstalling and reinstalling pyperclip using pip, and also installing an older version of the package (1.8.0) but the error persists.
Thanks for your help!

Python 2.7 Bloomberg blpapi import error on Mac OS X Sierra

After successful installation of the pybgg, when tried to run
$python test_pybbg.py
Got the following error message:
ImportError: No module named blpapi
MacBook:pfinance Allen$ which python
/Users/Allen/anaconda/bin/python
MacBook:pfinance Allen$ python test_pybbg.py
Traceback (most recent call last):
File "test_pybbg.py", line 2, in
import pybbg
File "/Users/Allen/anaconda/lib/python2.7/site-packages/pybbg/init.py", line 8, in
from .pybbg_k import Pybbg
File "/Users/Allen/anaconda/lib/python2.7/site-packages/pybbg/pybbg_k.py", line 8, in
import blpapi
ImportError: No module named blpapi
I used $pip list, but failed to see blpapi from the output list.
Any suggestions on how to fix my problem?
Thanks in advance
Ps. The followings show my installation log
MacBook:pfinance Allen$ pip install git+https://github.com/hubertrogers/pybbg
Collecting git+https://github.com/hubertrogers/pybbg
Cloning https://github.com/hubertrogers/pybbg to /private/var/folders/c6/7s88m85x0fj7l0zc52y_kcbh0000gn/T/pip-XagRDz-build
Installing collected packages: pybbg
Running setup.py install for pybbg ... done
Successfully installed pybbg-0.0.1
Based on the post I have set the library links properly;
MacBook:pfinance Allen$ echo $DYLD_LIBRARY_PATH
/Users/Allen/pfinance/blpapi_cpp_3.8.1.1/Darwin/
MacBook:pfinance Allen$ echo $BLPAPI_ROOT
/Users/Allen/pfinance/blpapi_cpp_3.8.1.1

Python 3.5 No Module named xlrd or pybrain

I am working on a project to build a Neural Net in python from an xlrd file, and I am encountering some issues. I have installed xlrd using pip install xlrd, and pybrain by cloning the git repository and running python setup.py install both of which were successful in installing. When I try to run import xlrd or import pybrain from IDLE, it gives the error:
>>> import xlrd
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import xlrd
ImportError: No module named 'xlrd'
and the same thing for pybrain. I only have python 3.5 installed. I am at the end of my rope with this, If anyone can give some insight in to why this may be happening I would be very appreciative.
Had this same problem with Python 3.6. Issue fixed by doing a PIP install of the XLRD.
pip install xlrd

Categories