Run TensorFlow using Pycharm, and Virtualenv installs TensorFlow
@(Machine Learning with Python)
System: MacOS 10.13
This section focuses on two issues:
Create a virtual environment with virtualenv and install TensorFlow in this environment to configure the interpreter under Pycharm and run the training code under Pycharm
Virtualenv + Tensorflow
TensorFlow can be installed under the Virtualenv virtual environment, or under the Anaconda virtual environment, or under Docker. The specific installation can be found on the TF official website, but the TF official website can be accessed only by scientific surfing on the Internet.
Here’s an excerpt of how Virtualenv is installed.
virtualenv --system-site-packages ~/tensorflow # Create a new virtual environment called tensorflow in your personal home directory.
source tensorflow/bin/activate # Enter the virtual environment.
easy_install -U pip # This step can be omitted if you already have a pip tool.
pip install --upgrade tensorflow # pip install tensorflow
deactivate # Exit the virtual environment
Pycharm configuration
Python script code needs to be executed under the interpreter, so we need to perform the following steps:
Pycharm -> Preference -> Project: Project Interpreter below Project Name click the lower triangle arrow to the right of the selection bar -> show all -> Click on the “+” – & gt; Add Local selects “~/tensorflow /bin/Python” and waits for loading
After loading, the red wavy line below the import tensorflow as tf
in the code disappears, but the buttons in the column where the code runs are all gray.
Don’t understand why at first, then understand, the most critical place is here…
This is because there is no optional execution configuration, so you need to manually edit it.
If there is no configuration, there is a Default. Clicking the “+” at the top will generate an interpretation environment configuration that can be used to execute the code based on the Default configuration.
Specifies that the script to be executed (entry) selects the interpreter
The previous set of the interpreter, here can also be re-selected, choose not installed TF interpreter, the code containing TF code will not be interpreted correctly.
As for the choice of the Python interpreter under the Anaconda virtual environment, there is no difference between Virtualenv and Virtualenv.
For example, I use Virtualenv in ~/</ code> to create the virtual environment, called tensorflow Anaconda is
/Applications/Anaconda envs/python27 </ code>, as well as the choice of approach: is to find the
bin/python </ code>.
As I understand it, the Python interpreter in the virtual environment is configured independently, but you can also use some of the tools of the global installation. With this independent interpreter, you can isolate the installation of some differentiated things, such as different versions of software packages, etc.
conda env list
Lists the virtual environment installed by Anaconda.
source activate envname
source deactivate
Read More:
- Tensorflow: How to Use static_rnn
- How To Install Java with Apt-Get on Ubuntu 16.04
- How to Install FFmpeg on Linux
- How to install PIL in Python 3
- How to Install PSSH in Centos7
- How to Solve Cython-bbox pip install Error
- How To Install WordPress with LAMP on Ubuntu 16.04
- How to Install MongoDB Community Edition Manually on mac and linux
- Debian: How to install MariaDB
- Mac: How to Install homebrew, nginx, PHP and MySQL
- How to Install Mongdb4.X in Windows
- Docker: How to Install Nacos
- Macos: How to Solve cocoapods Install Error
- How to Solve program install error 0x80070660
- How to Sole cmd Install typeScript Error
- How to Solve Oracle 11g Install Stuck 86% error on Linux
- Use Maven install to type the war package, which shows that the package XXX does not exist
- How to solve the error of “failed to create the Java virtual machine” in installing eclipse 2020-03 in MAC environment
- Mac: How to installs docker through brew
- How to Revert Your File & Folder by “FOUND.000”