Install working rosbag package for Jupyter Notebook (Python 3) - python-3.x

Trying to plot the data from ros topics in a rosbag file. My system by default had Python 2.7 and I installed Python 3.5 just to work with Jupyter notebooks.
Now I have installed several packages twice, once for Python 2 and again for Python 3. Although most packages are compatible with both versions of Python, I am beginning to wonder if all the ros packages are compatible here.
For the image in this question, initially I was getting an error 'No module named 'rosbag_pandas'', then I installed it with pip3. Now I am facing the error shown in the image with regards to rosbag. I have searched high and low for a quick fix but to no avail. I read online that some packages only work with either Python 2.7 or with Python 3.5. Is that what's happening here?
FYI I have installed pyrosbag with pip and pip3 both. Still facing this issue. Could really use some help with this.

I faced the same problem and found a workaround for me. Basically, on top of the usual python 3 installation, install a python 2 kernel for jupyter notebook, as described here, as follows:
python2 -m pip install pip
python2 -m pip install --upgrade ipykernel
python2 -m ipykernel install
Not sure if there is indeed a python 3 package for rosbag but using the python 2 kernel you can import rosbag files to save them in another format for further processing in python 3.

Related

Running python 3.7 on miniconda on raspberry pi

I want to use python 3.7 in raspberry pi through miniconda but surfing, I got to know that miniconda provides python version upto 3.4. Some sources said to use berryconda, which I installed but still the conda info states my python version is 3.6. I tried to install python 3.7 through conda install python=3.7. But as u might have guessed that didnt work as well. I do have python 3.7 manually installed but I don't think there is a way to make conda use that version (please correct me if I'm wrong and tell me how).
I want to create an environment with these dependencies, but it seems I'm stuck on the first step (python 3.7):
name: yolov4-cpu
dependencies:
python==3.7
pip
matplotlib
opencv
pip:
opencv-python==4.1.1.26
lxml
tqdm
tensorflow==2.3.0rc0
absl-py
easydict
pillow
Is there a solution for my problem?

How can I move from the default pre-installed Python 2.7 on my Mac to accessing Python 3.7 from Anaconda in Terminal?

I may be leaving out many details, but I'll attempt to construct the best picture of what is happening here.
My Mac is running OS Catalina 10.15.6, I got it back in April, and it has Python 2.7 in
I'm learning to use pip install and PyPI from terminal, and the first oddity I noticed was that I had to install pip. I shouldn't have, because it comes with Anaconda Navigator. So I did sudo easy-install pip and it installed. Then I did pip install requests which worked fine, then pip install colorama and then it threw this error message:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: colorama in ./Library/Python/2.7/lib/python/site-packages (0.4.3)
My desire is to be able to use the Anaconda Python from terminal, since this 2.7 Python is dying and I need to be able to do so for my upcoming bootcamp and current Python course. I tried many conda commands to create an environment, see my current environment, etc, and they all failed because my terminal doesn't recognize conda as a command. I see this:
ryanlindsey#Ryans-MacBook-Pro ~ % conda info --envs
zsh: command not found: conda
ryanlindsey#Ryans-MacBook-Pro ~ % conda create -n myenv python=3.6
zsh: command not found: conda
ryanlindsey#Ryans-MacBook-Pro ~ % conda
zsh: command not found: conda
I've read stack overflow suggestions to add it to my path, but even when I use the code it seems to do nothing.
If this is useful, here is my PATH when I do echo $PATH
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
My shell I am using is zsh.
Anyone experienced in solving problems like this?
MacOS comes with python 2.7 installed by default. You can't move or remove it. Catalina also comes with python 3.7 (though it requires the download of Xcode command line tools when first run to complete it.)
Usually, python 3 versions are instigated with the command python3. Similarly, pip3 manages libraries for python 3, while pip manages libraries for python 2.
It doesn't look like you've actually installed Anaconda. Anaconda is a third-party product, which does not come bundled with the OS. You'll need to install that and follow the instructions on their website.
https://docs.anaconda.com/anaconda/install/

Do I have different python versions and which one I am working with?

I am confused about different python versions on my Computer and in Anaconda.
First: I use an iMac (OSX Catalina).I sometimes use the command line (Terminal on my iMac) directly and sometimes I use Anaconda Navigator (for example when I want to work with Jupyter Notebooks).
When I type python3 --version, I get the answer that I have python 3.8.0 installed. But recently, I installed the latest pip version with pip3 --user --upgrade pip. The answer I got was:
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 20.0.2 from /Users/Andrea_5K/Library/Python/3.7/lib/python/site-packages/pip (python 3.7)
I wondered why in this message python 3.7 is referenced.
When I check my Library/Python folder in my user folder I see that I have a 3.7 folder and a 3.8 folder as well. Is there something wrong? Is pip 20.0.2 now installed on python 3.7 although I use python 3.8? And what does the WARNING message mean?

Installing Spacy is failing with Python 3.7 on Windows 10

Installing Spacy on Windows 10 with pip is failing. Installing any other of a number of modules is working fine for me.
Here is a pastebin containing the error message:
pip install -U spacy
or
python -m pip install spacy
output:
https://pastebin.com/Y9np4veN
I have tried this both with and without virtualenv and it is failing in the same manner either way. I have also already tried installing and updating setuptools. I've ensured that I am using Python 3.7 and pip3. There is no other version of python or pip installed on my PC.
I downgraded to Python 3.6 and was able to successfully install spacy
Using x86-64 ("64-bit") version of Python 3.7 (3.7.4) instead of x86 ("32-bit") one on Windows fixed the issue for me.

import ortools in mac

I am trying to run some code using ortools on a python environment. I did not have troubles on a windows machine but I am having problems on mac (10.12.6). if in my virtual environment I run
pip freeze
or
conda list
ortools appears in my list of installed packages. But if I try to use it
ipython
from ortools.linear_solver import pywrapplp
I get an error saying that there's no module named ortools. If I go to
mac/anaconda3/envs/nameenv/lib/python3.6/site-packages I do have a folder called ortools with some python files including pywrapplp. Do you know what I am doing wrong ?
EDIT
following request from coments:
import os
os.getcwd()
returns '/Users/imac'
which ipython
/anaconda3/bin/ipython
Installing ortools is a bit of a headache. It was some days ago, I think I finally made it with
easy_install ortools
I think it is a problem with the path. I guess because I did not install it with conda it does not find the package. I got around writting:
sys.path.append('/anaconda3/envs/env_name/lib/python3.6/site-packages/')
at the begining of my ipynb. That way I can run ortools.
You could have several python interpreter installed (python2 and python3)
So if you want to use it with ipython, which seems to be bind on python3 in your case.
First check if you have pypi package ortools installed
ipython -m pip show ortools
If you got an error it means the package is not installed.
so you can easily install it using:
ipython -m pip install --user ortools
note: We provide Pypi ortools package (64 bits) for Manylinux, Windows and MacOS.
You can also rebuild it from source https://developers.google.com/optimization/introduction/installing/source

Resources