I'm using numpy for mathematical projects in python3. Today, I wanted to use numpy.integrate.quad, but you can see the errors and further attemps below. import numpy always works. So what's the matter?
$ python
Python 3.6.1 (default, Mar 27 2017, 00:27:06)
[GCC 6.3.1 20170306] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import numpy.integrate as integrate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy.integrate'
>>> import scipy.integrate as integrate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scipy'
>>> from numpy import integrate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'integrate'
>>> from scipy import integrate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scipy'
>>> from numpy.integrate import quad
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy.integrate'
>>> from numpy import integrate.quad
File "<stdin>", line 1
from numpy import integrate.quad
Numpy seems to be installed correctly, but I still can't use numpy.integrate. Am I messing with the imports?
from scipy.integrate import quad
numpy doesn't have an integrate package; those are in the scipy part of the delivery.
Related
I have installed the pyproj.2.6.1 version, and I am using the python3.8.8; I can't correctly import the module query_utm_crs_info from pyproj package.
Here below the code :
from pyproj import Proj, Transformer, CRS
from pyproj.database import query_utm_crs_info
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyproj.database'
Similar problem with AreaOfInterest
from pyproj.aoi import AreaOfInterest
and I received this message
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyproj.aoi'
However, if I change it in to
from pyproj.transformer import AreaOfInterest
Any suggestions ?
https://pyproj4.github.io/pyproj/stable/api/database.html#pyproj.database.query_crs_info
query_crs_info was added in pyproj 3.
I am trying to use the forked version of python-gnupg: https://pypi.org/project/gnupg/
rather than the original: https://pypi.org/project/python-gnupg/
When I install "gnupg" to my conda environment I see this:
$conda list | grep gnupg
gnupg 2.2.17 he1f381d_0
but when I try to import that module, I get this not found error:
(my_env) $python
Python 3.7.7 (default, May 7 2020, 21:25:33)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gnupg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gnupg'
>>> import pretty_bad_protocol
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pretty_bad_protocol'
>>> from pretty_bad_protocol import gnupg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pretty_bad_protocol'
The docs for the forked version say to import gnupg and pretty-bad-protocol, but neither work for me. I can't figure out what I'm doing wrong. Has anyone else had success with this module? Thanks!
Working with Ubuntu 14.04
How to tell Sublime text 3 and SublimeREPL where to look for the python packages?
From my terminal, pip list returns a list with many python packages like that:
numexpr (2.2.2)
numpy (1.8.2)
oauthlib (0.6.1)
oneconf (0.3.7)
openpyxl (2.2.5)
PAM (0.4.2)
pandas (0.16.2)
However, inside Sublime text 3, on the console:
>>> import openpyxl
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'openpyxl'
>>> import pandas
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'pandas'
>>> import numpy
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'numpy'
From the SulbimeREPL console:
Python 3.3.6 (default, Jan 28 2015, 17:27:09)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pandas'
>>> import openpyxl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'openpyxl'
So, I assume that something needs to be set up.
You need to point SublimeRepl to the right interpreter.
Add to Settings -> Package Settings -> SublimeREPL -> Settings - User
{
"default_extend_env": {"PATH": "{PATH}:/usr/lib/python2.7"}
}
try this
python3 -m pip install --user openpyxl
Everything is obvious as the below image and the codes followed it :
I want to import a module that phycially there is in the D:\pyusb-1.0.0a2\usb, but I receive errors!
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import sys
>>> sys.path.append('d:\pyusb-1.0.0a2\usb')
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \uXXXX escape
>>> sys.path.append('d:/pyusb-1.0.0a2/usb')
>>> from usb import core
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from usb import core
ImportError: No module named 'usb'
>>> import core
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import core
File "d:/pyusb-1.0.0a2/usb\core.py", line 44, in <module>
import usb.util as util
ImportError: No module named 'usb'
>>> import usb.core
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
import usb.core
ImportError: No module named 'usb'
>>>
You need to append d:/pyusb-1.0.0a2/ to your Python path, and not d:/pyusb-1.0.0a2/usb/.
As you can see when trying to import core the error is no longer that your import failed, but that the usb.core module did not manage to import usb.util since there's no usb module available in your Python path, only modules inside usb, such as core or util.
Python's standard logging module is supposed to contain a useful captureWarnings function that allows integration between the logging and the warnings modules. However, it seems that my installation misses this function:
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.captureWarnings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'captureWarnings'
>>> import logging.captureWarnings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named captureWarnings
>>> import warnings
>>> import logging.captureWarnings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named captureWarnings
>>>
What am I doing wrong?
Unfortunately, there is no such method in Python 2.6.5's logging module. You need Python 2.7.