search
HomeDatabaseMysql TutorialMAC (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)!


Statement
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
How to Grant Permissions to New MySQL UsersHow to Grant Permissions to New MySQL UsersMay 09, 2025 am 12:16 AM

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

How to Add Users in MySQL: A Step-by-Step GuideHow to Add Users in MySQL: A Step-by-Step GuideMay 09, 2025 am 12:14 AM

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

MySQL: Adding a new user with complex permissionsMySQL: Adding a new user with complex permissionsMay 09, 2025 am 12:09 AM

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

MySQL: String Data Types and CollationsMySQL: String Data Types and CollationsMay 09, 2025 am 12:08 AM

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

MySQL: What length should I use for VARCHARs?MySQL: What length should I use for VARCHARs?May 09, 2025 am 12:06 AM

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

MySQL BLOB : are there any limits?MySQL BLOB : are there any limits?May 08, 2025 am 12:22 AM

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

MySQL : What are the best tools to automate users creation?MySQL : What are the best tools to automate users creation?May 08, 2025 am 12:22 AM

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

MySQL: Can I search inside a blob?MySQL: Can I search inside a blob?May 08, 2025 am 12:20 AM

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.