I just installed the R package 'reticulate' and I found it especially useful. But with one con that I need to re-install python module (i.e. pandas) I have already installed.
The python engine is miniconda and the evnv is by default.
How can I specify the python interpreter so that I dont need to re-install all the installed module?
(After some search, I guess it has sth to do with 'virtualenv-tools ' in reticulate?)
By the way, I used to execute python with pycharm and the interpreter is system interpreter located in c://python//python.exe
Any idea?
Have you looked at this page, you have to specify which Python engine you want, in this case miniconda, but just have to tell Rmarkdown where that is located on your computer using the use_python function.
```{r setup, include=FALSE}
library(reticulate)
use_python('/location/to/engine')
```
Related
I installed Python 3.5.1 from www.python.org. Everything works great. Except that you can't install pandas using pip (it needs visualstudio to compile, which I don't have). So I installed Anaconda (www.continuum.io/downloads). Now I can see pandas as part of the list of installed modules, but when I run python programs I still get:
ImportError: No module named 'pandas'
How do I set up my environment to use the modules from Anaconda?
Note: I have Anaconda's home directory and Library/bin on my path, as well as Python's home directory. I do not have PYTHONPATH or PYTHONHOME set, and I know I have the correct privileges to see everything.
I have successfully installed pandas for a Windows 32 bit version Python 3.4 with pre-complied code (no Visual Studio required) using the website:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyyaml
There is link for Python 3.5 pre-complied code at this site as well, but I have not tested it.
Download the code you want to a directory on your machine.
Using your Windows CMD.exe, go to your python directory and enter:
Python -w pip install "YourDirectory/pandas-0.18.1-cp35-cp35m-win32.whl"
OR
Python -w pip install "YourDirectory/pandas-0.18.1-cp35-cp35m-win_amd64.whl
Choose the version based on the version of Python you have
have, 32 bit or 64 bit.
Good Luck!
Anaconda has included one version of Python with it. You have to change your system environment path with Anaconda's instead of the former one to avoid conflict. Also, if you want to make the whole process easy, it is recommended to use PyCharm, and it will ask you to choose the Python interpreter you want.
I have installed iPython using pip in OS X 10.10, and it gave me the "ipython" and "ipython2" commands, which run great, but which use OS X's default python version 2.7.9. I downloaded and installed the latest release of Python3.4 and can load it with the command "python3," but cannot find a way to get iPython to use this version of python. The iPython Web site states the package can be used with python versions 3.3 and above, but I cannot find any instruction on how to change the default python version used.
So far I have found that the jupyter package for iPython has a kernel specification in /usr/local/share/jupyter/kernels/, which is just a folder called "python2" containing a json file that points to the system's python 2.7.6, but altering this to point to the new python3.4 installation does not work. My guess is this configuration is for the ipython notebook.
I've also tried the approach here: ipython reads wrong python version
In doing so I've duplicated the ipython2 command in /user/local/bin/ and edited it to use the python3 interpreter located at /Library/Frameworks/Python.framework/Versions/3.4/bin/python3, however, this gives me an error "ImportError: No module named 'IPython'," which suggests the python3 installation does not have ipython installed.
To tackle this, I've tried uninstalling ipython and reinstalling it using pip, but it just targets the system's Python 2.7 installation and does nothing for python3.
Does anyone know how to configure iPython to use a different python version, or even install a separate ipython installation for python3? Ultimately it would be nice to quickly switch back and forth depending on my needs.
I just found the answer. In essence, this stems from not understanding the python installation layout and how resources are separated between installed interpreters. It appears each python version will have its own repository of tools, and the current "pip" command I had installed on the system was mapped for use with python 2.7, so all libraries, tools, and other details it managed where available only to python 2.7. This included iPython.
I thought that installing python3 would make all these libraries available to the new interpreter by default, but it appears the system keeps them all separate (which makes sense). The main issue here was continuing to use "pip" which targeted the old installation, instead of the new "pip3" command included with python3. By using pip3 to reinstall iPython, I was able to get iPython3 installed properly.
Unfortunately this setup means needing to re-download other libraries, but that's not too difficult.
It might seem like a trivial issue in hindsight, but this had me completely stuck. I hope this helps someone else in this situation.
I've just installed Python 2.7.8 (as default version) following these steps. I was using Python 2.7.6 before this. I have been importing modules such as pyglet, gasp and pygame normally. Now, I can't import any of these (whenever I try, I get
No module named (some module)
error). I haven't changed anything. Each of these are properly installed. I even removed (with all dependencies) and installed pyglet again, but problem remained. Please help.
Are you sure you are installing the modules under new Python installation directory?
You need to install all the modules for the new Python version.
Check under your Python2.7.8 installation directory <PYTHON2.7.8_INSTALL_DIR>\Lib\site-packages\ whether you have all the needed modules or not.
To install into the modules under the new Python, use the new easy_install.exe or pip.exe under <PYTHON2.7.8_INSTALL_DIR>\Scripts
I am fairly new to Python and trying to install the Pillow package on Windows 7. I downloaded and ran the MS Windows installer Pillow-2.2.1.win-amd64-py3.3.exe from here. It appeared to install fine. If I run the simple line of code:
from PIL import Image
directly from the Python interpreter, it runs fine. A help() on PIL gives me the package contents.
But when I try to run the same line of code from within a script, I get an ImportError: No module named PIL. What am I missing?
(Note that I've been able to import sys and import MySQLdb from within scripts just fine.)
Resolved: sure, enough, I'm running Python 2.7 when I run scripts. (I think I vaguely recall having to install an older version so I could interface with MySQL.) Thank you all for pointing out that I should check the version being used.
For third-party modules for Windows, my go-to resource is Christoph Gohlke's Python Extension Packages for Windows. You can find the latest version of Pillow here. Make sure you're working with the python.org version of Python.
As far as your specific error, it's hard to tell exactly without a traceback, but make sure your script is calling the correct version of Python. If you have also installed Python 2.7, for example, your script may be calling that instead of 3.3.
In such cases I'm simply printing the sys.path at the beginning of the script in trouble and comparing it with the one from the working python interpreter. In most cases I was running the script with a different python interpreter.
In my case , I was referring to wrong pip folder.
Changed virtual environment in pycharm to point to right pip folder to solve this issue
import sys
print ( sys.path )
I am new to python and Canopy. I have searched for the possible solutions online, including the support forum of Enthought Canopy, but failed to solve my problem by following the instructions under other similar questions.
I use Mac OS, and wanted to install external python packages to my Enthought Canopy (specifically, a new package named "ggplot" (https://github.com/yhat/ggplot/)).
The instructions on the support forum of Enthought (https://support.enthought.com/entries/23389761-Installing-packages-into-Canopy-Python-from-the-command-line) said " follow standard Python installation procedures from the OS command line ". However, I could only install this package to my previous python library (system default python). When I want to import this module in Canopy, it failed. I thought I might need to change the installation path in order to install this package in Canopy, but not sure how to change and where to change.
When I want to use Sublime text to run my scripts when I set Enthought as default python env, it succeeded so I guess it still imported the package from my previous python library. How can I know which environment the editor is currently using?
Thanks!
1) The cited article links to another article, which describes how to make Canopy Python be the default python, and states that the easiest way is simply to use the Canopy Preferences dialog to make Canopy be your default Python.
If you prefer not to do that, the article suggests that you modify the PATH environment variable (note that this is not actually an "installation path" but a more general path used for locating programs to run for any reason.)
So I'm guessing that you don't know how to do this? Here's a simple way. From a terminal, type the following (substituting your own user name) before continuing with the installation:
export PATH=/Users/your-user-name/Library/Enthought/Canopy_64bit/User/bin:${PATH}
2) To find out what environment your editor is using, run the following program:
import sys
print sys.prefix