"Error: package not found" even after using pip to install - pip

I have successfully finished the first problem I had with pip.main being moved, but I installed pyfirmata which I am using for my Arduino UNO, but even though I used pip and successfully installed it, there was still an error that said "package pyfirmata not found". I don't understand this. This is my code:
#install pyfirmata
import pip
from pip._internal import main as pipmain
pipmain(['install', 'pyfirmata'])
#import pyfirmata
from pyfirmata import Arduino, util
import time
board = Arduino('') #put port into "('')"

if you are getting error no module named pyfirmata and it is sucessfully installed than again type pip install pyfirmata you see requirment satisfy and location of site packages open location search pyfimata and locate pyfirmata file to your project directory
now it possible pyfirmata need more module so also locate them with in the directory

Related

Can't get imports that are seen in "pip list"to be recognized in pycharm

I'm trying to get pyttsx3 to work in pycharm. I did a "pip3 install pyttsx3". "pip3 list" shows it to be available. I get the following when I try to run the module in pycharm:
from pywiktionary import WiktionaryParserFactory
ModuleNotFoundError: No module named 'pywiktionary'
It does the same thing for pyttsx3. Installs under pip, but get the same "ModuleNotFoundError: No module named 'pyttsx3'.
It's like they exist at one place for pip and another place for pycharm. I even uninstalled/installed pycharm. What defines where the python modules are put in the system?

How do I access a previously installed Python package?

I'm working in Visual Studio and want to use the ipywidgets package, but even after installing the package, I get the same "no module named 'ipywidgets'" error message.
I installed the ipywidgets package using conda install ipywidgets. However, when I went to import that package in my ipynb file, I got the same error "no module named 'ipywidgets'" that I had before I installed the package.

How can I add conda python libraries as ubuntu system root libraries

I am trying to import the scikit and dlib library in my editor. However, it shows module not found. Also, when I try to download the module, it shows that it already exist. I can easily open juptyer notebook via command line.
Even when it asks for password for root permission, it shows:
File "/lib/security/howdy/compare.py", line 17, in <module>
import dlib
ModuleNotFoundError: No module named 'dlib'
Unknown error: 1
However, when I try to install dlib, it shows that it is already installed in the anaconda directory.

ModuleNotFoundError for 'modin' even though it is installed by poetry

On import modin.pandas as modin_pd line I get ModuleNotFoundError: No module named 'modin'. I am using poetry & JupyterLab. If in the cell I type !poetry add modin, I get ValueError saying Package modin is already present.
So it cannot install modin because it is already installed but it cannot import it either. Any obvious solution that I am missing?
pip freeze command also shows modin to be installed. I also tried to install it via pip install but absolutely nothing let me to import this module in the end.
The problem may be this one KeyError: CPU
It can be solved by using pip install psutil

How to make cython a requirement for a pip install?

When creating a Python package and uploading it to pypi, it will automatically install the requirements that are put in the setup.py file under install_requires, e.g.
from distutils.core import setup
setup(
name = 'a_package',
packages = ['a_package'],
install_requires=['another_package']
)
When the package has a cython extension (and .pyx files instead of .c/.cpp files), the setup.py file will need to import cython to create an installable extension, e.g.
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
name = 'a_package',
packages = ['a_package'],
install_requires=['another_package'],
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension('the_extension', sources=['a_file.pyx'])]
)
But since Cython is imported before executing the setup part, when trying to install this package through pip from source (rather than from a wheel) downloaded from pypi, it will fail to install due to not being able to import cython, as it has not reached the part with the requirements yet.
I’m wondering what can be done to ensure that a pip install of this package from pypi will install cython before it tries to import it. Adding a requirements.txt with cython does not seem to add automatic-install requirements for files downloaded from pypi.
Now, I realize it’s possible to just pip install cython before pip install thispackage, but I’m wondering if there’s a better fix that would allow to install the package along with cython directly from pypi when it’s not possible to run an additional command (without resorting to uploading the .c. files and ajusting the setup.py file to use them instead of the .pyx).
What you're describing is a "build time dependency", and this is precisely the use case "PEP 518 -- Specifying Minimum Build System Requirements for Python Projects" was created for.
You can specify cython as a build-time dependency by adding a pyproject.toml file like:
[build-system]
requires = ["cython"]
Then when installing your package with a modern version of pip (or another PEP 518 compatible installer), cython will be installed into the build environment before your setup.py script is run.

Resources