Greeetings,
per instructions for IPython, I am supposed to be able to run this import when coding:
from IPython.lib.security import passwd_check
I have IPython 8.8.0 installed as part of a jupyter install.
however, when I attempt to run this library, it reports:
ModuleNotFoundError: No module named 'IPython.lib.security'
what am I missing?
THanks
It looks to me that the IPython.lib.security is not present anymore in version 8.x.
If you are using version 7x you should be able to import it with.
I was able to import successfully:
from IPython.lib.security import passwd_check
on my 7.x version
IPython.__version__
'7.25.0'
if you want to lower version you can try:
%pip install IPython==7.25.0
Related
I want to troubleshoot my environment which may have been affected by recently installed packages.
You can do something like this:
import os
import time
from pip._internal.utils.misc import get_installed_distributions
for package in get_installed_distributions():
print ("{}\t{}".format(time.ctime(os.path.getctime(package.location)), package))
Or you can use pip-date.
I get ImportError: no module named Flopy when I try to run the following script from an Anaconda prompt in the folder that the script it stored in, but when I run the script through Spyder it imports Flopy just fine and the rest of the code (not shown) which uses Flopy also works.
# import the required libraries
try:
import flopy
except:
fpth = os.path.abspath(os.path.join('..', '..'))
sys.path.append(fpth)
import flopy
The Spyder ran version never runs the code under than 'except' section since it managed to import Flopy at first try. I tried checking the path created by os.path.abspath(os.path.join('..', '..')) and even copied the Flopy directory to that location and running the script from the Anaconda prompt started in that folder...which did make some difference, but the import failed with error: ImportError: cannot import name getfullargspec.
Any ideas why imports work one way but not the other?
Fixed it with help from #Jainal Patel! I just had to tidy up all my environment paths. There was an installed version of Python in C:\Python3, but Spyder was using the one in C:ProgramData\Anaconda.
Now when I open the command prompt, or an Anaconda prompt, or use Spyder, it uses the same Python environment and recognizes all my installed packages.
!pip install flopy
try:
import flopy
except:
fpth = os.path.abspath(os.path.join('..', '..'))
sys.path.append(fpth)
import flopy
you need to install it first either using pip or conda
I am trying to import 'lightcurve' in sunpy. But unfortunately got an error
cannot import name 'lightcurve'
How can I resolve this issue?
first make sure the module is installed, open the command line (search cmd in start menu) then type
pip install lightcurve
Or if your on Linux open the terminal and type
sudo apt-get install python
then import the module like this into your code
import lightcurve
sunpy removed the lightcurve submodule and it was replaced with "timeseries".
An example of this is here: https://docs.sunpy.org/en/stable/generated/gallery/time_series/goes_hek_m25.html#sphx-glr-generated-gallery-time-series-goes-hek-m25-py
I would suggest that if you found a example or resource that uses lightcurve that is very old, that it is out of date and is fit for use.
The latest documentation is https://docs.sunpy.org/en/stable/
In Google colab I am to trying import BucketIterator using:
from allennlp.data.iterators import BucketIterator
But it is raising the same error again and again-
ModuleNotFoundError: No module named 'allennlp.data.iterators
After installing allennlp with the imports:
from allennlp.data.token_indexers import TokenIndexer, SingleIdTokenIndexer
from allennlp.data.tokenizers.character_tokenizer import CharacterTokenizer
from allennlp.data.vocabulary import Vocabulary
from allennlp.modules.seq2vec_encoders import PytorchSeq2VecWrapper
are working fine. Is there a way to solve this issue?
I was facing the same issue.
It won't work, since Iterators are removed from allennlp.
Install a legacy version of allennlp. allennlp is depended upon the PyTorch(torchtext) library. And since torchtext removed iterators form their newer versions allennlp did it too.
You can directly use torchtext.data.BucketIterator(). Use:
pip install torchtext==0.5.0 --user
I've installed pandas using pip3. I'm able to import pandas in the MacOS terminal without issue, but whenever I try to import it in Atom, using the script package, I get an error.
This error is:
ImportError: No module named pandas
I don't get this error when trying to import numpy in Atom.
I assume you are using Script package to run python scripts in Atom.
Following approach worked for me.
Lets first check which python version Atom is using. Try this in Atom.
import sys
print('Python: {}'.format(sys.version))
If you see output as python version 2.x then
Point Atom to use python 3 by updating Atom ->Preferences -> Open Config Folder ->Packages -> Script->lib->grammars->python.coffee. Change
command: 'python' to command: 'python3' .
Save and Close Atom.
Run your code again to check python version. Now it should say 3.x
pip install pandas
You can run following python code in atom to check versions of commonly used python libraries for ML.
# Check the versions of libraries
# Python version
import sys
print('Python: {}'.format(sys.version))
# scipy
import scipy
print('scipy: {}'.format(scipy.__version__))
# numpy
import numpy
print('numpy: {}'.format(numpy.__version__))
# matplotlib
import matplotlib
print('matplotlib: {}'.format(matplotlib.__version__))
# pandas
import pandas
print('pandas: {}'.format(pandas.__version__))
# scikit-learn
import sklearn
print('sklearn: {}'.format(sklearn.__version__))
i had this in some new files I created to test Pandas, but on closer inspection I found I was missing this line in my new files, as I was adding the library:
#!/usr/local/bin/python3
On adding this definition it worked perfectly via Python3.