Ask Your Question
-1

importErrors when coding with rospy

asked 2018-01-27 07:42:57 -0600

OperationCrossbow gravatar image

updated 2018-03-04 14:29:12 -0600

jayess gravatar image

I still have no Idea what I'm doing, so keep in mind that I have no idea on earth what "rebuid your JPMML-SparkML-Package EGG file" means, or what "build your numpy again" means. Coding is evil.

Context

Ubuntu 16.04 LTE, Xenial, Kinetic, python 2.7, anaconda 2, trying to use python files to analyse bagfile messages.

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import numpy as np
import scipy.io
from FileSelectGui import getFilePath
from bag import get_topic_data
testfile = getFilePath("example")
testdata = get_topic_data(testfile,"/NIS")

I've downloaded and installed python, and added to .bashrc:

export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages

(due to answer: https://answers.ros.org/question/3965... )

I've downloaded and installed anaconda2, and added to .bashrc:

export PATH="/home/pieter/anaconda2/bin:$PATH"

If i don't do the first, I get "importError: rospkg"

If i do the first, I get: "importError: cannot import name multiarray"

All I find about multiarray results is builgin numpy packages and source paths to python, and I can't make heads or tails of it, if I'm honest.

Question

Are the errors arising from contradictions between rospy installations and anaconda installations? Are bashrc lines the cause of this problem? Or, what is it i'm missing?

edit retag flag offensive close merge delete

Comments

2

I've downloaded and installed python, and added to .bashrc:

export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages

why?

gvdhoorn gravatar imagegvdhoorn ( 2018-01-27 08:32:44 -0600 )edit
3

and I can't make heads or tails of it, if I'm honest.

for now - as long as you don't feel comfortable enough with Python, class/python/search paths, avoid using Anaconda, and use the regular Python (2.7). Things will work out-of-the-box, and you can focus on learning one thing.

gvdhoorn gravatar imagegvdhoorn ( 2018-01-27 08:33:59 -0600 )edit

There are some work-arounds / workflows that make using Anaconda possible (it essentially comes down to pkgs having been installed for your system Python instead of Anaconda. See #q263430 and #q244644 for related questions.

gvdhoorn gravatar imagegvdhoorn ( 2018-01-27 08:36:24 -0600 )edit

Python 2.7 is not regular python anymore. This should not be the advice in 2018. Nobody is using Python 2.

neuronet gravatar imageneuronet ( 2018-10-07 21:47:09 -0600 )edit

That's nice and that is recognised, but the reality is that many ROS packages are not Python 3 compatible.

You have to keep in mind that "ROS packages" includes all packages that are contributed by users.

If they do not upgrade their packages, we cannot blanketly give the advice to use Python 3.

gvdhoorn gravatar imagegvdhoorn ( 2018-10-08 01:10:13 -0600 )edit

Additionally: Anaconda is not "regular python" either. The issue the OP reports has more to do with the fact that he's using an alternative interpreter than a 2 vs 3 problem.

The suggestion was to use the "system Python", not necessarily "Python 2.7". That was just added to clarify to the OP.

gvdhoorn gravatar imagegvdhoorn ( 2018-10-08 01:11:10 -0600 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2018-01-31 01:29:39 -0600

tfoote gravatar image

The default installation of ROS is not designed to work with anaconda. It can be made to work but you will need to understand your PYTHONPATH manipulations and installation directories well.

Similarly it's highly recommended that you stick with the system version of python instead of downloading and installing advanced tools.

I'd recommend starting with a fresh installation and install ROS following the instructions: http://wiki.ros.org/ROS/Installation

then going through the core ROS Tutorials: http://wiki.ros.org/ROS/Tutorials

what "rebuid your JPMML-SparkML-Package EGG file" means, or what "build your numpy again" means. Coding is evil.

before you try to execute these directions you will need to learn the fundementals and the context in which they are stated. For reference I have no idea what the JPMML-SparkML-Package is or how to rebuild it. But it likely has it's own set of instructions and you'll need to understand how to merge that context with any other context that your using. Which is what the basic ROS tutorials try to teach you. This is your responsibility to learn and understand, don't expect people to be able to put it all together for you. Please see the guide for asking questions http://wiki.ros.org/Support to help you structure your questions.

edit flag offensive delete link more

Comments

it's highly recommended that you stick with the system version of python instead of downloading and installing advanced tools

Anaconda is the default scientific computing platform. Suggesting people not use it should be a deprecated response. This is going to be a deal breaker for many.

neuronet gravatar imageneuronet ( 2018-10-07 21:45:46 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-01-27 07:42:57 -0600

Seen: 715 times

Last updated: Jan 31 '18