{"action":"opened","issue":{"url":"https://api.github.com/repos/yihui/knitr/issues/1062","labels_url":"https://api.github.com/repos/yihui/knitr/issues/1062/labels{/name}","comments_url":"https://api.github.com/repos/yihui/knitr/issues/1062/comments","events_url":"https://api.github.com/repos/yihui/knitr/issues/1062/events","html_url":"https://github.com/yihui/knitr/issues/1062","id":90946744,"number":1062,"title":"How to run Python code in virtual environment?","user":{"login":"zhuzelong","id":8529410,"avatar_url":"https://avatars.githubusercontent.com/u/8529410?v=3","gravatar_id":"","url":"https://api.github.com/users/zhuzelong","html_url":"https://github.com/zhuzelong","followers_url":"https://api.github.com/users/zhuzelong/followers","following_url":"https://api.github.com/users/zhuzelong/following{/other_user}","gists_url":"https://api.github.com/users/zhuzelong/gists{/gist_id}","starred_url":"https://api.github.com/users/zhuzelong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhuzelong/subscriptions","organizations_url":"https://api.github.com/users/zhuzelong/orgs","repos_url":"https://api.github.com/users/zhuzelong/repos","events_url":"https://api.github.com/users/zhuzelong/events{/privacy}","received_events_url":"https://api.github.com/users/zhuzelong/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-25T12:19:30Z","updated_at":"2015-06-25T12:19:30Z","closed_at":null,"body":"I use Python 3 with `venv` module. I did not find documentation about how to tell knitr to activate a virtual environment and then evaluate the Python code.\r\n\r\nBesides, I wrote a Rmd document as:\r\n\r\n    Test document.\r\n    \r\n    ```{r, setup}\r\n    library(knitr)\r\n    opts_chunk$set(engine='python')\r\n    ```\r\n\r\n    ```{python}\r\n    import numpy as np\r\n    import pandas as pd\r\n    ```\r\n\r\n    A Python code block.\r\n\r\n    ```{python}\r\n    # Create a data frame in Python\r\n    df = pd.DataFrame(\r\n             {\r\n                 'A': [1, 2, 3, 4],\r\n                 'B': [10, 20, 30, 40],\r\n                 'C': [100, 50, -30, -50]\r\n             }\r\n         )\r\n\r\n     print(df)\r\n     ```\r\n\r\nBut RStudio raised an error: `Error in engine(options): ImportError: No module named pandas Calls`.\r\n\r\nWould you please help me out? Thank you."}}