I want to use pandas2ri in JUPYTER but tzlocal issue? - pandas

Everytime I try to import the pandas2ri in jupyter, python interface:
from rpy2.robjects import pandas2ri
I get the following error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-28-cc52694d111a> in <module>()
----> 1 from rpy2.robjects import pandas2ri
/Users/sondosayyash/anaconda/lib/python3.6/site-packages/rpy2/robjects/pandas2ri.py in <module>()
21 import numpy
22 import pytz
---> 23 import tzlocal
24 import warnings
25
ModuleNotFoundError: No module named 'tzlocal'
I tried to use
from dateutil.tz import tzlocal
but that didn't seem to fix the issue.
I've already installed tzlocal and it is on my computer. When I import pandas2ri on ipython, there is no problem.. the problem only occurs when calling in the jupyter environment.
this is the message I get when I try to install tzlocal again:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020.
Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: tzlocal in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (1.5.1)
Requirement already satisfied: pytz in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from tzlocal) (2017.2)

I had a similar issue when running rpy2 in Jupyter. I did not have the package installed previously. I just installed the package and the error went away. You can try installing the package again to see if it helps resolve your issue.
pip install tzlocal
I must add that I am using Python 3.6.8 not 2.7

If using conda:
conda install tzlocal
worked.

I had a similar issue as yours. It turns out that my local lib did not have the tzlocal package. So I installed the package through Anaconda prompt:
pip install tzlocal
And the issue is gone.

Related

Medspacy colab install

Can anyone get medspacy to work on colab? I have tried reinstall of python 3.8 but no dice. I have tried installing medspacy via pip
Traceback (most recent call last)
in
1 import spacy
----> 2 import medspacy
3 from spacy.tokens import Span
4 from medspacy.sentence_splitting import PyRuSHSentencizer
5 from medspacy.section_detection import Sectionizer
ModuleNotFoundError: No module named 'medspacy'
NOTE: If your import is failing due to a missing package, you can
manually installCan anyone get medspacy to work on colab? I have tried reinstall of python 3.8 but no dice. I have tried installing medspacy via pip
low.
Can anyone get medspacy to work on colab? I have tried reinstall of python 3.8 but no dice. I have tried installing medspacy via pip.

What is the working combination of the s3fs and fsspec version? ImportError: cannot import name 'maybe_sync' from 'fsspec.asyn'

I am using the latest version of s3fs-0.5.2 and fsspec-0.9.0, when import s3fs, encountered the following error:
File "/User/.conda/envs/py376/lib/python3.7/site-packages/s3fs/__init__.py", line 1, in <module>
from .core import S3FileSystem, S3File
File "/User/.conda/envs/py376/lib/python3.7/site-packages/s3fs/core.py", line 11, in <module>
from fsspec.asyn import AsyncFileSystem, sync, sync_wrapper, maybe_sync
ImportError: cannot import name 'maybe_sync' from 'fsspec.asyn' (/User/.conda/envs/py376/lib/python3.7/site-packages/fsspec/asyn.py)
what is a working combination version of s3fs and fsspec?
The latest version of s3fs and fsspec as of today is 2021.11.0. The latest version on conda-forge is 2021.10.1 . Since the change to calendar versioning this year, the two are always released together and the dependency pinned, so that this kind of problem won't occur in the future.
I believe for fsspec 0.9.0, you need s3fs 0.6.0 .
In my case the same happened. 'maybe_sync' was missing from 'fsspec.asyn'. For me, the following worked.
!pip install --upgrade awscli
!pip install --upgrade boto3
!pip install --upgrade git+https://github.com/dask/s3fs

Cant run modules

everytime after downloading a module a cant run it, what im doing wrong?
I've installed it using:
pip install pyperclip
It has been installed succesfully:
C:\WINDOWS\system32>pip list
Package Version
--------------- ---------
certifi 2020.6.20
clipboard 0.0.4
colorama 0.4.3
cycler 0.10.0
handcalcs 0.8.1
kiwisolver 1.2.0
matplotlib 3.3.1
numpy 1.19.1
Pillow 7.2.0
pip 20.2.3
pyparsing 2.4.7
pyperclip 1.7.0
python-dateutil 2.8.1
qrcode 6.1
six 1.15.0
sqrc 0.0.3
But when running the code, this is what a get:
import pyperclip
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pyperclip
ModuleNotFoundError: No module named 'pyperclip'
Any help on this?
That can be specific for a programming platform you are using. Some platforms like PyCharm enable to install modules directly from themselves so using modules becomes much easier.

Installed BeautifulSoup but still get no module named bs4

I'm using a Jupyter notebook, Python 3.5, and a virtual environment.
Within my virtual env I did:
(venv) > pip install BeautifulSoup4
Which seemed to run fine b/c the terminal output was:
Downloading beautifulsoup4-4.6.0-py2-none-any.whl (86kB)
100% |████████████████████████████████| 92kB 297kB/s
Installing collected packages: BeautifulSoup4
Successfully installed BeautifulSoup4-4.6.0
But when I run my Jupyter notebook I get:
ImportError Traceback (most recent call last)
<ipython-input-1-5fe69888b1a1> in <module>()
5 from itertools import groupby
6 import pickle
----> 7 import bs4
8 import matplotlib.pyplot as plt
9 get_ipython().run_line_magic('matplotlib', 'inline')
ImportError: No module named 'bs4'
And I can't change the line import bs4 to from bs4 import BeautifulSoup which I've seen on other SO posts b/c its read-only and I'm not supposed to
Since you are using Python 3, I think you needed to do
pip3 install BeautifulSoup4
Just pip install would have been for the Python 2 package.
Other things to check:
First make sure you ran both the BeautifulSoup install in your virtualenv, and the python3 prompt or Jupyter notebook in your virtualenv. If you did the install in your root environment and the notebook is run in your virtualenv, or vice versa, you might have a mismatch in your site-packages directory.
Ensure that your package indeed installed by typing pip3 list at a command prompt, and noting that it appeared in the list.
Check that you Jupyter notebook is indeed running a Python 3.5 kernel (upper right hand corner of the browser window)
Check that the path where the package is installed is in your sys.path
Open a Python3 prompt or in Jupyter and run
import sys
print (sys.path)
I had the same problem, bs4 was installed in my virtual environment along with Jupyter Lab. Jupyter would throw the ModuleNotFound Error but if I opened the notebook in Visual Studio Code and chose the .venv as the interpreter, it worked.
I got it to work in Jupyter Lab by uninstalling from the virtual environment and installing with sudo apt-get install python3-bs4 instead.

No module named 'pandastable'

I'm trying to change table wrote by me on tkinter with the pandastable one in order to do the handling of data directly from a pandas.DataFrame.
But despite I have already installed Anaconda3 with matlplotlib, numpy, pandas ect. modules when i would like to import pandastable I have trouble.
This is the problem:
import pandastable
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
import pandastable
ImportError: No module named 'pandastable'
pip install pandastable
Requires python>=3.3 or 2.7 and numpy, matplotlib and pandas.
See: pandastable on github
edit: You may have multiple Python environments installed on your machine. Anaconda uses conda install to keep things in check but pandastable doesn't seem to be available through Anaconda packages. Make sure you are installing to the same Python environment that your script uses. You might also try:
pip3 install pandastable