简体   繁体   English

Django,Python 3.4,CentOS 6.4,virtualenv:ImportError:没有名为Django的模块

[英]Django, Python 3.4, CentOS 6.4, virtualenv: ImportError: No module named Django

I am running a Linux server with CentOS 6.4. 我正在使用CentOS 6.4运行Linux服务器。 I need to run Django 1.8.2 with Python 3.4. 我需要用Python 3.4运行Django 1.8.2。 I already have pip and virtualenv installed, and I am currently in a virtual env. 我已经安装了pip和virtualenv,我目前处于虚拟环境中。 I tried to install Django using the pip command but it has installed it in the Python 2.6 site packages, so when I run a python 3 interpreter and type import django I get ImportError: No module named Django . 我尝试使用pip命令安装Django,但它已经将它安装在Python 2.6站点包中,所以当我运行python 3解释器并输入import django我得到ImportError: No module named Django I need to find a way to install Django with Python 3.4. 我需要找到一种用Python 3.4安装Django的方法。 I do not have pip3 and cannot figure out how to install it. 我没有pip3,也无法弄清楚如何安装它。 All of the help I have found on other sites deals with Ubuntu systems and do not work for me. 我在其他网站上找到的所有帮助都与Ubuntu系统有关,对我不起作用。

EDIT: 编辑:

which pip outputs ~/MAP_VIO/bin/pip which python3 outputs /usr/local/bin/python3 which python outputs ~/MAP_VIO/bin/python which pip输出~/MAP_VIO/bin/pip which python3输出/usr/local/bin/python3 which python输出~/MAP_VIO/bin/python

MAP_VIO is my virtual env, so it looks like I don't have python 3 in my virtual env? MAP_VIO是我的虚拟环境,所以看起来我的虚拟环境中没有python 3? If that's my problem, how do I solve it? 如果这是我的问题,我该如何解决?

It seems you installed a Python 2 virtual environment. 您似乎安装了Python 2虚拟环境。 To get a Python 3 environment you need to do 要获得Python 3环境,您需要这样做

virtualenv -p python3 venv_path

The -p flag tells it which interpreter you want. -p标志告诉它你想要哪个解释器。 That should install both pip3 and setuptools into the environment. 这应该将pip3和setuptools安装到环境中。 If you really don't have pip3 (which virtualenv can copy into the environment) and can't install it system wide for some reason, try doing 如果你真的没有pip3(virtualenv可以复制到环境中)并且由于某种原因无法在系统上安装它,请尝试

easy_install pip

inside the virtual environment. 在虚拟环境中。 That should be able to fetch and install the right pip for the virtual environment you're in. 这应该能够为您所在的虚拟环境获取并安装正确的点。

Please see that you are using the correct, virtualenv'ed, pip command. 请注意您使用的是正确的virtualenv'ed, pip命令。

You can verify this by running command: 您可以通过运行命令来验证这一点:

  which pip

... and it will tell you the absolute path of pip command (and Python installation) you are using. ...它会告诉你正在使用的pip命令(和Python安装)的绝对路径。

Also do the same for python command you are trying to run Django with. 对于尝试运行Django的python命令也一样。 If necessary edit your question and add the relevant information about virtualenv, python and pip paths. 如有必要,请编辑您的问题并添加有关virtualenv,python和pip路径的相关信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM