Issue with importing scipy.integrate or scipy.integrate.quad - scipy

This might be something really simple: I am using Python 2.6.5 and I am unable to load any integration module in my working space. Everything is OK when I import scipy, but if I try to import scipy.integrate or scipy.integrate.quad I get an error message from python. Any clue?? Thanks.

Try from scipy import integrate.

Related

VSCode Pylance can't find import

I'm using Django.
The issue happens when I import a module I defined like so import project.helpers.
If I import project.helpers as helpers it works fine.
Any solutions to this?

AttributeError: module 'torchtext' has no attribute 'legacy'

I am trying to use torchtext to process test data, however, I get the error: "AttributeError: module 'torchtext' has no attribute 'legacy'", when I run the following code. Can anyone please guide me what the issue here? I am using python 3.10.4. Thanks
import pandas as pd
import torch
import torchtext
import spacy
def prep_data(file_path):
TEXT=torchtext.legacy.data.Field(tokenize='spacy', tokenizer_language='en_core_web_sm')
LABEL=torchtext.legacy.data.LabelField(dtype=torch.long)
fields=[('clean_text', TEXT), ('label',LABEL)]
dataset = torchtext.legacy.data.TabularDataset(
path=file_path, format='csv',
skip_header=True, fields=fields)
print(dataset.examples[0])
if __name__=="__main__":
train_path='./data/train.csv'
test_path='./data/test.csv'
prep_data(train_path)
I addressed the same issue by updating the torchtext.
pip install torchtext==0.9
I also had the same issue. I solved my problem by using a pytorch stable version You are probably using versions 0.10, and 0.11. These were the versions using legacy.
Please update to the latest versions 0.13 and 0.14.
pip install torchtext==<version>

ImportError: No module named 'pvlib'

I am using Jupiter notebook ipython for solar power forecasting. When I import the pvlib it gives error "ImportError: No module named 'pvlib'".
enter image description here
ImportError basically says that the library/package you are trying to import is not available. So try re-installing that package and check once again. Hopefully, it will work. If you feel that this is not the problem then kindly let us know.
Please see the pvlib installation instructions: https://pvlib-python.readthedocs.io/en/latest/installation.html

import statsmodels package returns ModuleNotFound despite correct path

I am trying to import statsmodels.stats.weightstats.DescrStatsW.tconfint_mean.
I run
from statsmodels.stats.weightstats.DescrStatsW import tconfint_mean
I get the error
ModuleNotFoundError: No module named
'statsmodels.stats.weightstats.DescrStatsW';
'statsmodels.stats.weightstats' is not a package
I have confirmed that I can import other packages from statsmodels with no problems.
I must be using the wrong path, but the docs don't specify any other path to use.
I just figured it out. I will leave this up for progeny.
from statsmodels.stats.weightstats import DescrStatsW
DescrStatsW.tconfint_mean(...)
Not sure why this behaves differently from other python libraries.

Virtualenv PyDev Undefined variable from import error

First of all I'm aware of the question here but I couldn't find a satisfied answer there. I don't want to ignore errors or use comments - I want to have the right settings in eclipse/pydev. My problem is pretty similar to this one.
I'm using Ubuntu 12.04 and installed a virtuenv for python 2.7 in my home directory. After installing several python packages (numpy, scipy, matplotlib, etc.) using pip, I installed eclipse 4.3 with pydev.
If I use the python system interpreter at /usr/bin/python everything works fine (except that I didn't want to use). However, if I try to set up a python interpreter using the virtualenv first I get this warning describe here. After clicking "proceed anyway", it seems to work. So far so good.
However e.g. import numpy as np gives for each np.* call the eclipse/pydev error Undefined variable from import, also the code completion doesn't work properly. It seems to work, e.g. for datetime, but not for numpy, scipy and matplotlib.
Does anybody figured out to configure eclipse correctly?
I already tried to add the numpy path manually to the virtualenv interpreter, but than I get the weird error:
import matplotlib.dates as mpl_dates
File "/home/pydev/myenv-py27/local/lib/python2.7/site-packages/matplotlib/init.py", line 149, in
import sys, os, tempfile
File "/usr/lib/python2.7/tempfile.py", line 34, in
from random import Random as _Random
ImportError: cannot import name Random