I am installing django-easy-pdf, xhtml2pdf and reportlab using pip I installed the following in a virtual environment.:
$ pip install django-easy-pdf
$ pip install "xhtml2pdf>=0.0.6" "reportlab>=2.7,<3"
But after the testing, there is an import error that has following message:
from reportlab.lib import PyFontify
ImportError: cannot import name PyFontify
Oh, I nearly forgot, when I'm installing the reportlab, this came up in the middle of the setup:
running build_ext
building '_rl_accel' extension
error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).
Get it from http://aka.ms/vcpython27
----------------------------------------
Rolling back uninstall of reportlab
I solved this by removing the packages and their dependencies and installing it again.
Related
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.
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
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
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.
I've installed this package via pip27 on macports. My OS is OSX El Capitan 10.11.6. My python install is 2.7.10.
I'm trying to run an example script that imports googlemaps module, but I keep getting that ImportError. I have a feeling that it's how pip installed it and the reason why python can't find it, but I'm relatively new to pip so I don't know where to start investigating.
I also tried googling for a fix but no dice. Any idea what's happening here?
Here's my code:
import googlemaps # can't import
import argparse
from datetime import datetime
# collect args for lat, long, # of addresses, radius of search
parser = argparse.ArgumentParser(description='Randomize addresses on Google Maps')
parser.add_argument('-lt', '--latitude')
parser.add_argument('-lng', '--longitude')
parser.add_argument('-n', '--count')
parser.add_argument('-r', '--radius')
args = parser.parse_args()
print('Results: ', vars(args))
Error message:
Traceback (most recent call last):
File "randomize_addresses.py", line 1, in <module>
import googlemaps
ImportError: No module named googlemaps
Found a fix. I uninstalled googlemaps via pip and then reinstalled using easy_install. Apparently OSX doesn't like pip.
Looks like you used pre-installed python since you mentioned version 2.7.10 (default version shipped with macOS) which is located at /usr/bin/.
MacPorts installs binaries and libraries under /opt/local. Try to install python via MacPorts and run the program again. Python and pip should both be linked so that packages installed via pip is available to python.
In this case packages installed using pip27 would be available to python27 installed via MacPorts and not /usr/bin/python.
Another way would be to download get-pip.py and install it against /usr/bin/python (pip installation guide).
Note: Make sure you are using python installed via MacPorts. To check this run which python, it should show something like /opt/local/bin/python2.7