When I start the server. /manage.py, I get an ImportError: No module named celery

I am trying to run manage.py runningerver from my virtual environment and when I do, I get this message

    Traceback (most recent call last):
      File "./manage.py", line 10, in <module>
        execute_from_command_line(sys.argv)
      File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
        utility.execute()
      File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 302, in execute
        settings.INSTALLED_APPS
      File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 55, in __getattr__
        self._setup(name)
      File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 43, in _setup
        self._wrapped = Settings(settings_module)
      File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 99, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
        __import__(name)
      File "/Users/ray/Desktop/sub_desk/myheroku/practice/src/gettingstarted/__init__.py", line 4, in <module>
        from .celery import app as celery_app
      File "/Users/ray/Desktop/sub_desk/myheroku/practice/src/gettingstarted/celery.py", line 6, in <module>
        from celery import Celery
    ImportError: No module named celery

      

I not only have celery, but it also uses python 2.7 outside of virtenv. When I type this python, when I am in or out of the environment, they both come from the same place, which, according to the python hitchhiker's guides, should be separated. What's happening? shouldn't I use python from virtual env?

Then when I tried to install pip django-celery I got the following

    (practice) apples-MBP:src ray$ pip install django-celery
    Collecting django-celery
      Downloading django_celery-3.2.1-py2-none-any.whl (63kB)
        100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 71kB 2.9MB/s 
    Requirement already satisfied: django>=1.8 in /Library/Python/2.7/site-packages (from django-celery)
    Collecting celery<4.0,>=3.1.15 (from django-celery)
      Downloading celery-3.1.25-py2.py3-none-any.whl (526kB)
        100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 532kB 1.9MB/s 
    Collecting billiard<3.4,>=3.3.0.23 (from celery<4.0,>=3.1.15->django-celery)
      Using cached billiard-3.3.0.23-cp27-none-macosx_10_6_intel.whl
    Requirement already satisfied: pytz>dev in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from celery<4.0,>=3.1.15->django-celery)
    Collecting kombu<3.1,>=3.0.37 (from celery<4.0,>=3.1.15->django-celery)
      Using cached kombu-3.0.37-py2.py3-none-any.whl
    Collecting anyjson>=0.3.3 (from kombu<3.1,>=3.0.37->celery<4.0,>=3.1.15->django-celery)
      Using cached anyjson-0.3.3.tar.gz
    Collecting amqp<2.0,>=1.4.9 (from kombu<3.1,>=3.0.37->celery<4.0,>=3.1.15->django-celery)
      Using cached amqp-1.4.9-py2.py3-none-any.whl
    Installing collected packages: billiard, anyjson, amqp, kombu, celery, django-celery
    Exception:
    Traceback (most recent call last):
      File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
        status = self.run(options, args)
      File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
        prefix=options.prefix_path,
      File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install
        **kwargs
      File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
        self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
      File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
        isolated=self.isolated,
      File "/Library/Python/2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
        clobber(source, lib_dir, True)
      File "/Library/Python/2.7/site-packages/pip/wheel.py", line 323, in clobber
        shutil.copyfile(srcfile, destfile)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
        with open(dst, 'wb') as fdst:
    IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/_billiard.so'

      

+3


source to share


5 answers


First of all, in your virtual environment, install Celery :

pip install -U Celery

      

If you get IOError: [Errno 13] Permission denied:

as shown in your example (which means you have this problem and you can / should merge it by following the link provided) then use:

sudo pip install -U Celery 

      

Thereafter:

python manage.py runserver

      



and check if that fixes your problem.

Note:

You can install the project interpreter in PyCharm in your virtual environment.

  • Go to File> Preferences> Project:> Project Translator.
  • In the project interpreter click on the Cog icon and select "Add Local"
  • To find ~/.virtualenvs/<venv_name>/bin/python

  • Apply then OK

Good luck :)

+1


source


install celery in your virtualenv:

pip install django-celery

      



while in your virtualenv run your django app:

python manage.py runserver

      

0


source


A good test is typing pip freeze

wherever you use this. It will print all installed packages.

0


source


Run cmd as administrator which works for me all the time.

0


source


try uninstalling '/Library/Python/2.7/site-packages/_billiard' and reinstalling.

-2


source







All Articles