Install local dist package into virtualenv

mirandak

I have a pytest test, let's call it test.py. I used to run this test outside of virtualenv; now I'm trying to run it inside a virtualenv sandbox.

The project is structured like this:

~/project/test # where test.py and all virtualenv files live
~/project/mylibrary

test.py imports from mylibrary. In the past, this worked because I have the code in ~/project/mylibrary installed into /usr/lib/python2.7/dist-packages/mylibrary.

I can't run virtualenv with the --system-site-packages flag. I also can't move the code from ~/project/mylibrary into the ~/project/test folder. How can I get access to the code in mylibrary inside my virtualenv?

ali_m

You don't need to do anything special - as long as you are working inside a virtualenv, python setup.py install will automatically install packages into

$VIRTUAL_ENV/lib/python2.7/site-packages

rather than your system-wide

/usr/lib/python2.7/dist-packages

directory.

In general it's better to use pip install mylibrary/, since this way you can neatly uninstall the package using pip uninstall mylibrary.

If you're installing a working copy of some code that you're developing, it might be a good idea to install it in "editable" mode using pip install -e mylibrary/, which creates a link to your source directory so that your installed module gets updated as you edit the code.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

virtualenv中的Python easy_install提供setuptools错误

来自分类Dev

Unable to install XML package in R on CentOS

来自分类Dev

Create virtualenv in existing directory without creating a "local" directory

来自分类Dev

如何让virtualenv在Ubuntu上使用dist-packages?

来自分类Dev

can't install virtualenv on ubuntu 12.04

来自分类Dev

ACTION_INSTALL_PACKAGE

来自分类Dev

pip install PIL不会安装到virtualenv中

来自分类Dev

Install only one package from package.json?

来自分类Dev

Autoloading local composer package

来自分类Dev

调用`composer install`应该只使用satis dist zip文件,不要使用source

来自分类Dev

package.json与“ npm install%s -g”

来自分类Dev

virtualenv versus setup.py install --user

来自分类Dev

virtualenv与setup.py install --user

来自分类Dev

ghc-pkg:无法创建:dist / dist-sandbox-XXXXXXXX / package.conf.inplace已存在

来自分类Dev

Unable to install cachem package for R

来自分类Dev

将本地dist软件包安装到virtualenv

来自分类Dev

错误:无法创建'/usr/local/lib/python2.7/dist-packages/sklearn':权限被拒绝

来自分类Dev

“ npm install [package]”不会更新package.json

来自分类Dev

npm install不会创建dist文件夹

来自分类Dev

npm脚本,捆绑时将package.json复制到dist

来自分类Dev

如何回滚“ apt-get install dist-upgrade”?

来自分类Dev

npm install无法读取package.json

来自分类Dev

如何回滚“ apt-get install dist-upgrade”?

来自分类Dev

package.json与“ npm install%s -g”

来自分类Dev

OSError:[Errno 13]权限被拒绝:'/usr/local/lib/python2.7/dist-packages/pelican-3.6.3.dist-info'

来自分类Dev

权限被拒绝:'/usr/local/lib/python2.7/dist-packages/pytz-2017.2.dist-info'

来自分类Dev

Is there any way to install a transient package?

来自分类Dev

为什么python在virtualenv中看不到dist-packages?

来自分类Dev

通过 pip install virtualenv 安装时出现 UnicodeDecodeError

Related 相关文章

  1. 1

    virtualenv中的Python easy_install提供setuptools错误

  2. 2

    Unable to install XML package in R on CentOS

  3. 3

    Create virtualenv in existing directory without creating a "local" directory

  4. 4

    如何让virtualenv在Ubuntu上使用dist-packages?

  5. 5

    can't install virtualenv on ubuntu 12.04

  6. 6

    ACTION_INSTALL_PACKAGE

  7. 7

    pip install PIL不会安装到virtualenv中

  8. 8

    Install only one package from package.json?

  9. 9

    Autoloading local composer package

  10. 10

    调用`composer install`应该只使用satis dist zip文件,不要使用source

  11. 11

    package.json与“ npm install%s -g”

  12. 12

    virtualenv versus setup.py install --user

  13. 13

    virtualenv与setup.py install --user

  14. 14

    ghc-pkg:无法创建:dist / dist-sandbox-XXXXXXXX / package.conf.inplace已存在

  15. 15

    Unable to install cachem package for R

  16. 16

    将本地dist软件包安装到virtualenv

  17. 17

    错误:无法创建'/usr/local/lib/python2.7/dist-packages/sklearn':权限被拒绝

  18. 18

    “ npm install [package]”不会更新package.json

  19. 19

    npm install不会创建dist文件夹

  20. 20

    npm脚本,捆绑时将package.json复制到dist

  21. 21

    如何回滚“ apt-get install dist-upgrade”?

  22. 22

    npm install无法读取package.json

  23. 23

    如何回滚“ apt-get install dist-upgrade”?

  24. 24

    package.json与“ npm install%s -g”

  25. 25

    OSError:[Errno 13]权限被拒绝:'/usr/local/lib/python2.7/dist-packages/pelican-3.6.3.dist-info'

  26. 26

    权限被拒绝:'/usr/local/lib/python2.7/dist-packages/pytz-2017.2.dist-info'

  27. 27

    Is there any way to install a transient package?

  28. 28

    为什么python在virtualenv中看不到dist-packages?

  29. 29

    通过 pip install virtualenv 安装时出现 UnicodeDecodeError

热门标签

归档