如何 设置 默认的python路径

dick_china 2013-01-07 12:43:08
情况是这样的
我在ubuntu里想装个python
但是系统自带了python2.7,而我需要python3.3
于是我安装到了另外一个目录,两者共存了,同时也修改/usr/bin/python的link指向python3.3的。
这个时候看起来所有都正常,我直接输入python test.py,能够成功运行。

但是接着我需要使用python的mysqldb模块,于是通过apt-get去install了一个mysqldb。结果这个模块被自动安装到了python2.7目录下了,于是我就蒙了,。。。不知道怎么处理从而是install的时候可以安装到python3.3里。

我初玩ubuntu等linux类型的系统,所以很多不懂,麻烦大神指点下,如何处理这个问题
...全文
2340 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
maniachhz 2013-01-09
  • 打赏
  • 举报
回复
当然你需要确保你安装的pip是3.3版本的.
maniachhz 2013-01-09
  • 打赏
  • 举报
回复
你可以使用pip(或者easy_install)来安装python模块.
crifan 2013-01-08
  • 打赏
  • 举报
回复
和: How do I change the installation directory for apt-get? How do I use dpkg to install? 中说的:
引用
from man dpkg: "--root=dir | --admindir=dir | --instdir=dir Change default directories. admindir defaults to /var/lib/dpkg and contains many files that give information about status of installed or uninstalled packages, etc. instdir defaults to / and refers to the directory where packages are to be installed. instdir is also the directory passed to chroot(2) before running pack‐age’s installation scripts, which means that the scripts see instdir as a root directory. Changing root changes instdir to dir and admindir to dir/var/lib/dpkg" probably should copy /var/lib/dpkg/* to your new admindir
crifan 2013-01-08
  • 打赏
  • 举报
回复
找了半天,貌似这里的: Install with apt-get in other path 提到的:
引用
you could use the -d option to get the packages, and then dpkg has an option "--root=<directory> Install on alternative system rooted elsewhere" which might be what you're looking for.
你可以去试试。
dick_china 2013-01-08
  • 打赏
  • 举报
回复
有人能再提供点意见吗?
dick_china 2013-01-07
  • 打赏
  • 举报
回复
引用 2 楼 zjs100901 的回复:
不熟 unix 系列。 那个“#!/usr/bin/env python”中的 env,能从 env 里做文章不?
现在是我调用apt-get install python-mysqldb就会自动将mysqldb更新安装到系统的python2.7下 而实际上我是希望他安装到python3.3下
dick_china 2013-01-07
  • 打赏
  • 举报
回复
引用 4 楼 bugs2k 的回复:
ubuntu的很多系统脚本采用的是python 2.x, 缺省python改成3.x,会不会导致ubuntu出问题呢?
不会吧,这么坑爹,那。。。。难道老老实实的写python2.7 还是说有什么办法手动去更新添加mysqldb模块 应该能手动控制的吧?
bugs2k 2013-01-07
  • 打赏
  • 举报
回复
ubuntu的很多系统脚本采用的是python 2.x, 缺省python改成3.x,会不会导致ubuntu出问题呢?
wopabe 2013-01-07
  • 打赏
  • 举报
回复
通过sys添加下路径试试 在Windows下应该是这样的
zjs100901 2013-01-07
  • 打赏
  • 举报
回复
不熟 unix 系列。 那个“#!/usr/bin/env python”中的 env,能从 env 里做文章不?
dick_china 2013-01-07
  • 打赏
  • 举报
回复
有没人知道如何设置,并且通过apt-get install 某个python模块的时候,能够安装到指定的python目录中,而不是安装到默认的python2.7里去

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧