简体   繁体   中英

pyenv + virtualenv not finding deluge

I'm trying to use deluge from a virtualenv build with PYENV.
For this purpose, I used pyenv to build a python 2.7.9.
I've set pyenv global to 2.7.9 and then installed the deluge package with:

apt-get install deluged deluge-console

Everything went fine, but when I try to do :

import deluge

it gives ImportError.

A pip freeze from inside 2.7.9 enviroment correctly display the deluge package:

spadazz@Deluger:~/.pyenv/versions/2.7.9$ pip freeze
apt-xapian-index==0.44
chardet==2.0.1
command-not-found==0.2.44
deluge==1.3.11

Doing a check with dpkg -l on ubuntu installed packages for deluge, I can see that deluge python package can be found at /usr/lib/python2.7/dist-packages, so adding this path to python sys.path, allows me to manually import the package.

My problem is this can't be manual and the deluge package is not requested by a program of mine, but from flexget package, that runs smoothly in this configuration.

I'm not experienced in pyenv and I can't find a simple way to setup a PYTHON_PATH under a pyenv virtualenv, or any other workaround that allows me to call deluge package in system's python under the virtualenv.

Any suggestions ?

TIA Enrico

  • Running from Ubuntu Server 12.04
  • pyenv 20150326-483-g10d5d9a

The Python module deluge is installed to your system python when you apt-get install deluged I belive (I could be mistaken though).

Kinda sucks that this Python module deluge is not available via pip, but you should be able to install it into your virtualenv with the following:

First off, have your virtualenv of choice activated, then run

mkdir ~/my_lovely_directory && cd ~/my_lovely_directory
git clone git://deluge-torrent.org/deluge.git
cd deluge
git checkout -b 1.3-stable origin/1.3-stable
python setup.py build
python setup.py install

Note: At this time of writing the Python module deluge is at version 1.3.13, if it is ~1.4 or higher at time of reading you might want to checkout different branch above, see list of branches with git branch -a .

You should now see a package called something like this deluge (1.3.13.dev0) when running pip list in your selected virtualenv.

If everything looks good you can clean up a bit with

cd ~/ && rm -rf ~/my_lovely_directory

Sources:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM