Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Module is found by python2.7 but not python3.4 in debian 8

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
deutschluz
Posts: 3
Joined: 2013-09-17 00:26

Module is found by python2.7 but not python3.4 in debian 8

#1 Post by deutschluz »

Hello Debian User forum,
I m trying to use a python module in python3.4 but I did the whole PythonPath variable thing in my .bashrc file and the module only works with python 2.7. If I run python3.4 interactively and try to import the module, the interpreter tells me there s no such module

In detail, assume $ is a bash prompt, # is a comment, >>> is python prompt; I did all of this:

$ emacsclient ~/.bashrc #yes i use emacs as my editor server

In emacs now:

export PYTHONPATH="${PYTHONPATH}:path/to/module"
Close emacs

$ source ~/.bashrc

$ python2.7

'>>>' import Module as M

'>>>' # it works

However if I do

$python3.4
'>>>' import Module as M
error no such module

What is going here and how do i get python3.4 to find this module. Also, I got it from a github repo and so I didn't use APT. I have a hunch thats going to be very important.

fred barclay
Posts: 124
Joined: 2015-01-24 03:10

Re: Module is found by python2.7 but not python3.4 in debian

#2 Post by fred barclay »

There's a good chance that module doesn't exist for python 3, or has a different name. I can't tell you how many times this has tripped me up when translating between versions... :D

It'd help, though, if you said exactly which module it is. ;)

deutschluz
Posts: 3
Joined: 2013-09-17 00:26

Re: Module is found by python2.7 but not python3.4 in debian

#3 Post by deutschluz »

Thanks for the reply.

Yeah I should ve mentioned that in the OP. Its networkx, a graph data structures/algos package.

Also I went looking in the Debian Python Policy Appendix and that really didn't help. I really didn't know what I was looking for.

fred barclay
Posts: 124
Joined: 2015-01-24 03:10

Re: Module is found by python2.7 but not python3.4 in debian

#4 Post by fred barclay »

Yep, there's definitely two versions--one for python2, and one for python3.

Try installing the python 3 one:

Code: Select all

sudo apt-get install python3-networkx
Hopefully it should import as normal afterwards. :)

Cheers!
Fred

deutschluz
Posts: 3
Joined: 2013-09-17 00:26

Re: Module is found by python2.7 but not python3.4 in debian

#5 Post by deutschluz »

fred barclay wrote:Yep, there's definitely two versions--one for python2, and one for python3.

Try installing the python 3 one:

Code: Select all

sudo apt-get install python3-networkx
Hopefully it should import as normal afterwards. :)

Cheers!
Fred
oh..thats great. thanks for the help!

fred barclay
Posts: 124
Joined: 2015-01-24 03:10

Re: Module is found by python2.7 but not python3.4 in debian

#6 Post by fred barclay »

No worries, mate. :D

Post Reply