Home Database Mysql Tutorial MAC (Mountain Lion)+Eclipse+python+Django+PyDve+MySQL 开发环境搭建

MAC (Mountain Lion)+Eclipse+python+Django+PyDve+MySQL 开发环境搭建

Jun 07, 2016 pm 03:02 PM
eclipse mac 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)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

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: The Ease of Data Management for Beginners MySQL: The Ease of Data Management for Beginners Apr 09, 2025 am 12:07 AM

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.

How to fill in mysql username and password How to fill in mysql username and password Apr 08, 2025 pm 07:09 PM

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.

Query optimization in MySQL is essential for improving database performance, especially when dealing with large data sets Query optimization in MySQL is essential for improving database performance, especially when dealing with large data sets Apr 08, 2025 pm 07:12 PM

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

Can I retrieve the database password in Navicat? Can I retrieve the database password in Navicat? Apr 08, 2025 pm 09:51 PM

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.

How to create navicat premium How to create navicat premium Apr 09, 2025 am 07:09 AM

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.

How to view mysql How to view mysql Apr 08, 2025 pm 07:21 PM

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;

How to copy tables in mysql How to copy tables in mysql Apr 08, 2025 pm 07:24 PM

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).

See all articles