MAC (Mountain Lion)+Eclipse+python+Django+PyDve+MySQL 开发环境搭建
MAC平台上安装Eclipse+python+Djgano+PyDve 开发环境搭建 比较复杂 我花了好多时间 才安装成功!
主要难点在于:
(一) 多版本的软件安装路径可能有所改变 导致软件之间不能快速的找到你所安装最新版本的路径,假如你所安装的Eclipse没能找到你所安装的Python路径
你需要手动添加Python Intrepreter的路径,我这次安装Python的路径为/usr/local/bin/pythonw 所以一开始EClipse就一直为找到正确的路径,导致编译出错!
(二) MySQl的安装比较费力 主要是除了安装官方提供的两个安装包外 还需要安装python-mysqldb 负责会出现错误!
0.安装JDK
在JDK官网http://www.php.cn/选择合适的版本,注意32位和64位的区别。
Mountain Lion 是64位的操作系统 所以以下所有软件 都选择64位的安装包!
1. 安装Python和Django:
1.1 Python
MAC中已经安装Python 你可以升级到最新的稳定版,我这次使用的是Python2.7
下载地址:http://www.php.cn/
1.2 Django(http://www.php.cn/)
Django的下载地址: http://www.php.cn/
解压后到文件所在目录,执行:
python setup.py install
安装 Django
django安装是否成功的测试也简单,进入python编辑环境,
输入:import django
然后输入:django.VERSION
如果能够正确显示版本号,则说明成功。
2. 安装eclipse
下载Eclipse 解压后运行Eclipse:
通过eclipse->Windows->Preferences->Install/Update->Available Software Sites增加Pydev网址,然后通过eclipse->help->Install New Software...进行安装PyDev
PyDev的eclipse下载地址:http://www.php.cn/
配置PyDev,Preferences->Pydev->Interpreter-Python点Auto Config创建Python工程: File->New->Other...->Pydev Project,
测试开发环境:src上右键new->Pydev Module->...Hello.py里输入 print('hello'),F9运行成功
然后打开Eclipse,选择Window -> Preferences -> Pydev- > Interpreter-Python,然后在右侧的“Python Interpreters”面板中选择New,
在弹出的对话框的“Interpreter Name”写Python,在“Interpreter Executable”中定位到python的地址,然后一直选择“ok”即可:
3.安装MySQL数据库:
Mysql:http://www.php.cn/
MysQLWorkbench: http://www.php.cn/
4. 安装Eclipse中开发Python的插件PyDev
5.安装python-mysqldb
下载MySQL-python-1.2.3.tar 下载地址:http://www.php.cn/
解压后进入到MySQL-python目录下修改文件site.cfg中的行
#mysql_config = mysql_config = /usr/local/bin/mysql_config
将注释去掉
修改为mysql_config = mysql_config = /usr/local/bin/mysql_config所在的路径
你可以尝试通过命令行执行
#python setup.py build
#python setup.py install
进行安装 !假如安装失败:
则通过xcode安装Command Line Tool 来安装Gcc 编译工具;
下载地址:http://www.php.cn/
安装完成后!在到MySQL-python目录下 执行:
#python setup.py build
#python setup.py install
假如顺利执行,没有报错的话!你可以执行python
然后导入MySQLdb尝试是否安装成功!
#python
>>>import MySQLdb
5.创建Django WebSite 工程连接数据库MySQL:
创建Django website:File->New->Other...->Pydev Django Project,Run as Django,然后打开http://www.php.cn/:8000/.
复制:http://www.php.cn/:8000/在浏览器中打开:
manage.py常用命令:
django-admin.py startproject mysite:新建项目。
manage.py runserver IP port:启动django自带服务器。
manage.py shell:启动django后台shell。
manage.py startapp appname:建立一个app。
manage.py validate:校验模型是否正确。
manage.py sqlall appname:生成create table语句。
manage.py syncdb:为模型生成相应表。
以上就是MAC (Mountain Lion)+Eclipse+python+Django+PyDve+MySQL 开发环境搭建的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

To fill in the MySQL username and password: 1. Determine the username and password; 2. Connect to the database; 3. Use the username and password to execute queries and commands.

1. Use the correct index to speed up data retrieval by reducing the amount of data scanned select*frommployeeswherelast_name='smith'; if you look up a column of a table multiple times, create an index for that column. If you or your app needs data from multiple columns according to the criteria, create a composite index 2. Avoid select * only those required columns, if you select all unwanted columns, this will only consume more server memory and cause the server to slow down at high load or frequency times For example, your table contains columns such as created_at and updated_at and timestamps, and then avoid selecting * because they do not require inefficient query se

Navicat itself does not store the database password, and can only retrieve the encrypted password. Solution: 1. Check the password manager; 2. Check Navicat's "Remember Password" function; 3. Reset the database password; 4. Contact the database administrator.

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

View the MySQL database with the following command: Connect to the server: mysql -u Username -p Password Run SHOW DATABASES; Command to get all existing databases Select database: USE database name; View table: SHOW TABLES; View table structure: DESCRIBE table name; View data: SELECT * FROM table name;

Copying a table in MySQL requires creating new tables, inserting data, setting foreign keys, copying indexes, triggers, stored procedures, and functions. The specific steps include: creating a new table with the same structure. Insert data from the original table into a new table. Set the same foreign key constraint (if the original table has one). Create the same index. Create the same trigger (if the original table has one). Create the same stored procedure or function (if the original table is used).
