my fixed pyOpenSSL version 19.0.0 suddenly broke - python

I have a Django app running on an old CentOS 7 box, and to have my own python3 environment there I'm using venv and pip. Today I rebuilt my environment, and suddenly, I had an ssl related backtrace.
[root#miketug1 teleworker]# vpython manage.py showmigrations
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/tug/env/lib64/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/lib/tug/env/lib64/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/usr/lib/tug/env/lib64/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/lib/tug/env/lib64/python3.6/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/usr/lib/tug/env/lib64/python3.6/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/etc/e-smith/web/django/teleworker/dashboard/models.py", line 9, in <module>
import teleworker.lib.common as commonlib
File "/etc/e-smith/web/django/teleworker/lib/common.py", line 35, in <module>
import requests
File "/usr/lib/tug/env/lib64/python3.6/site-packages/requests/__init__.py", line 95, in <module>
from urllib3.contrib import pyopenssl
File "/usr/lib/tug/env/lib64/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/tug/env/lib64/python3.6/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/lib/tug/env/lib64/python3.6/site-packages/OpenSSL/SSL.py", line 664, in <module>
_lib.Cryptography_HAS_TLSEXT_HOSTNAME, "SNI not available"
AttributeError: module 'lib' has no attribute 'Cryptography_HAS_TLSEXT_HOSTNAME'
The versions of my modules are set in a requirements.txt file, which did not change. I was running pyOpenSSL 19.0.0, with Python 3.6. I upgraded to pyOpenSSL 20.0.0 and the problem went away, but I am confused as to how this could happen unless the 19.0.0 version on PyPI was changed, as I've used fixed versions of this module for some time now.
Can anyone explain what happened here? I'd like to avoid anything similar in the future. Thanks.

The root cause for this issue is the latest cryptography-3.3 package which was released 20 hours ago; unfortunately, the pyopenssl-19 has a weird requirement (cryptography >=2.3) hence the pip install automatically upgraded the cryptography to 3.3.

We have both pip and pip3 installed. So the following sequence is what fixed it for me:
sudo apt update; pip install -U cryptography; sudo apt remove python3-openssl -y; sudo apt autoremove; pip3 install -U cryptography;

I think I found it. I didn't have the cryptography module in my requirements.txt, so it was upgraded to the latest version without upgrading pyOpenSSL which was in my requirements.txt file. Seems like some kind of dependency should have prevented this, but I'm updating my requirements.txt to include everything now.

There's a new cryptography 3.3.1 which fixes the issue

Related

How to fix a bad upgrade of pip on python3

Before someone slaps my hand, I had installed venv/virtualenv to setup virtual environments but I had other issues so someone suggested I upgrade my pip3 version to the current version (22.0.4 right now)
I somehow messed up both pip and pip3 so hopefully someone can help me.
I tried to upgrade my version of pip on my Ubuntu 16.04 box by running
pip3 install --upgrade pip
I also tried running
pip3 install --upgrade pip3
After upgrading, I kept getting errors when trying to run pip3 so I removed it, planning to install with the get-pip.py script.
However, now when I try to install pip3 using
sudo python3 /tmp/get-pip.py
I keep getting an AttributeError:
$ sudo python3 /tmp/get-pip.py
Traceback (most recent call last):
File "/tmp/get-pip.py", line 27077, in <module>
main()
File "/tmp/get-pip.py", line 135, in main
bootstrap(tmpdir=tmpdir)
File "/tmp/get-pip.py", line 111, in bootstrap
monkeypatch_for_cert(tmpdir)
File "/tmp/get-pip.py", line 92, in monkeypatch_for_cert
from pip._internal.commands.install import InstallCommand
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/tmp/tmpu1lmh2fr/pip.zip/pip/_internal/commands/__init__.py", line 9, in <module>
...
...
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/tmp/tmpu1lmh2fr/pip.zip/pip/_vendor/pyparsing.py", line 5677, in <module>
File "/tmp/tmpu1lmh2fr/pip.zip/pip/_vendor/pyparsing.py", line 1488, in setResultsName
File "/tmp/tmpu1lmh2fr/pip.zip/pip/_vendor/pyparsing.py", line 1491, in _setResultsName
File "/tmp/tmpu1lmh2fr/pip.zip/pip/_vendor/pyparsing.py", line 1445, in copy
AttributeError: module 'copy' has no attribute 'copy'
Can someone point me to instructions on how to re-install pip/pip3 or how to get around this AttributeError? Hopefully the solution will also keep my old modules that I had downloaded from before too. Thanks
Check if there is a file /tmp/copy.py or directory+file /tmp/copy/__init__.py. Try these commands: sudo python3 -c "import copy; print(copy.copy)" and sudo python3 -c "import copy; print(copy.__file__)"
If any of those exists it will be imported instead of standard module copy because Python prepends the directory of a script (the script is /tmp/get-pip.py, the directory /tmp/) at the beginning of sys.path so it's where Python starts to find modules/packages.

PyOpenSSL with ffi.from_buffer(b"") Error

Cannot import or even install anything using pip after installing pyopenssl. Getting the following error
***Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in <module>
sys.exit(main())
File "/home/srnadmin/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/home/srnadmin/.local/lib/python3.5/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/srnadmin/.local/lib/python3.5/site-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/home/srnadmin/.local/lib/python3.5/site-packages/pip/_internal/cli/req_command.py", line 15, in <module>
from pip._internal.index.package_finder import PackageFinder
File "/home/srnadmin/.local/lib/python3.5/site-packages/pip/_internal/index/package_finder.py", line 21, in <module>
from pip._internal.index.collector import parse_links
File "/home/srnadmin/.local/lib/python3.5/site-packages/pip/_internal/index/collector.py", line 12, in <module>
from pip._vendor import html5lib, requests
File "/home/srnadmin/.local/lib/python3.5/site-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/home/srnadmin/.local/lib/python3.5/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/local/lib/python3.5/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/local/lib/python3.5/dist-packages/OpenSSL/crypto.py", line 15, in <module>
from OpenSSL._util import (
File "/usr/local/lib/python3.5/dist-packages/OpenSSL/_util.py", line 152, in <module>
with ffi.from_buffer(b""):
TypeError: from_buffer() cannot return the address of the raw string within a bytes or unicode or bytearray object***
Can anyone please help me with this?
Got it to work
rm -rf /usr/local/lib/python3.5/dist-packages/OpenSSL/
pip3 uninstall pyopenssl
easy_install pyopenssl
It happened to me as well. (I'm running Python 3.7 on MacOS Catalina with Anaconda).
So apparently that's a problem with either cryptography module. Even pip uninstall wasn't working.
You could use this link for finding out the location of the cryptography package and delete it. Once deleted, just do pip install --upgrade cryptography and it will just work fine.
But in my case that wasn't working. So here's what I did:
Activate your env which has this problem. That could be done using conda activate <env_name> or source <path_to_env>/bin/activate.
(If there's no env, just skip this step)
Next execute where python or just conda info --envs if you're using anaconda. This should give you the path to the python executable. In my case it was ~/opt/anaconda3 as the output for conda info --envs.
Next just cd into that directory and then remove (or move it somewhere else in case you want a backup) the ~/opt/anaconda3/bin/python/cryptography folder. Or you could even do find . | grep cryptography after cding in the particular env folder to know the exact location of the package.
Next execute pip install --upgrade cryptography. In case that didn't work, you could try the same with the pyopenssl package.
Hope it helped.

"ModuleNotFoundError: No module named 'bootstrap4' " occured when deploying django project to PythonAnywhere

I'm trying to deploy my django project to PythonAnywhere referring to https://tutorial.djangogirls.org/en/deploy/.
When I executed this command,
pa_autoconfigure_django.py --python=3.6 https://github.com/my_git_url.git
The following error happened: (actually some texts are omitted because it's long)
Traceback (most recent call last):
File "/home/kanchi0914/kanchi0914.pythonanywhere.com/manage.py", line 21, in <module>
main()
File "/home/kanchi0914/kanchi0914.pythonanywhere.com/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/kanchi0914/.virtualenvs/kanchi0914.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/kanchi0914/.virtualenvs/kanchi0914.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/kanchi0914/.virtualenvs/kanchi0914.pythonanywhere.com/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/kanchi0914/.virtualenvs/kanchi0914.pythonanywhere.com/lib/python3.6/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/kanchi0914/.virtualenvs/kanchi0914.pythonanywhere.com/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/home/kanchi0914/.virtualenvs/kanchi0914.pythonanywhere.com/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'bootstrap4'
Traceback (most recent call last):
File "/home/kanchi0914/.local/bin/pa_autoconfigure_django.py", line 52, in <module>
django-bootstrap4andbootstrap4 seems to be correctlly installed.
23:45 ~ $ pip3.6 install --user django-bootstrap4
Looking in links: /usr/share/pip-wheels
Requirement already satisfied: django-bootstrap4 in ./.local/lib/python3.6/site-packages (1.0.1)
Requirement already satisfied: beautifulsoup4 in /usr/lib/python3.6/site-packages (from django-bootstrap4) (4.6.0)
I guessed these sites would be useful, tried some solutions, but situation did not change.
https://www.tangowithdjango.com/book17/chapters/deploy.html
https://www.pythonanywhere.com/forums/topic/12404/
Off cource I confirmed my project work well in my local env.
What should I do?
thanks.
I had this one time. Maybe you have to use pip3 if you are using python 3. Or pip if you are using python 2. Packages installed with pip3 won't work in python 2 and vice versa if your python version is 2. Not sure if this helps.

What should I do to use python-magic on Heroku?

I'm building an application that is using python-magic 0.4.15. On my local machine, python-magic-bin 0.4.15 works like a charm (Windows) but I'm trying to make it work on Heroku. First I'm just trying to get the tests to pass in the Heroku-CI. I added the package to my requirements.txt:
python-magic==0.4.15
And pushed it to Heroku. And it gets installed correctly:
-----> Installing requirements with pip
Collecting python-magic==0.4.15 (from -r /app/requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/42/a1/76d30c79992e3750dac6790ce16f056f870d368ba142f83f75f694d93001/python_magic-0.4.15-py2.py3-none-any.whl
Installing collected packages: python-magic
Successfully installed python-magic-0.4.15
But then it crashes like this:
+ python manage.py collectstatic --no-input
Traceback (most recent call last):
File "manage.py", line 20, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 120, in populate
app_config.ready()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/core/admin.py", line 8, in <module>
from .forms import CrmDataUploadForm
File "/app/core/forms.py", line 3, in <module>
from magic import magic
ImportError: cannot import name 'magic'
I tried adding the NetsoftHoldings/heroku-buildpack-magic buildpack and I can see it's being downloaded:
-----> Fetching https://github.com/NetsoftHoldings/heroku-buildpack-magic.git buildpack...
buildpack downloaded
The pip package is being correctly installed:
-----> Installing requirements with pip
Collecting python-magic==0.4.15 (from -r /app/requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/42/a1/76d30c79992e3750dac6790ce16f056f870d368ba142f83f75f694d93001/python_magic-0.4.15-py2.py3-none-any.whl
Installing collected packages: python-magic
Successfully installed python-magic-0.4.15
but then there seems to be an error with the buildpack (I'm guessing here):
-----> libmagic app detected
bash: /tmp/buildpacks/27353aa3b5edb2f8361186206e863f5d481f02805d02f0efdec439f3d30349a4fbdad2951af33a0492023fb0d90d26dafda6fe76f1b2d34f68564a98545f7022/export: No such file or directory
RootDir: /tmp/buildpacks/ba9220b10d71b7b776013869da2c820ccb5c0f1733268ae2515b3b8ad5edd44d2016d1119bce32d1660fbd84da179891a404dcc57df043b9d82e22725739b072
BuildDir: /app
HOME: /app
Build list
config
Home list
config
and it eventually crashes like this:
+ python manage.py collectstatic --no-input
Traceback (most recent call last):
File "manage.py", line 20, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 120, in populate
app_config.ready()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/core/admin.py", line 8, in <module>
from .forms import CrmDataUploadForm
File "/app/core/forms.py", line 3, in <module>
from magic import magic
ImportError: cannot import name 'magic'
Then I tried adding the heroku-community/apt buildpack and an Aptfile containing:
libmagic-dev
libmagic1
and I can see them being installed correctly:
-----> Fetching .debs for libmagic-dev
Reading package lists...
Building dependency tree...
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 23 not upgraded.
Need to get 79.4 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 libmagic-dev amd64 1:5.32-2ubuntu0.1 [79.4 kB]
Fetched 79.4 kB in 0s (222 kB/s)
Download complete and in download only mode
W: --force-yes is deprecated, use one of the options starting with --allow instead.
-----> Fetching .debs for libmagic1
Reading package lists...
Building dependency tree...
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 23 not upgraded.
Need to get 68.4 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 libmagic1 amd64 1:5.32-2ubuntu0.1 [68.4 kB]
Fetched 68.4 kB in 0s (199 kB/s)
Download complete and in download only mode
W: --force-yes is deprecated, use one of the options starting with --allow instead.
-----> Installing libmagic1_1%3a5.32-2ubuntu0.1_amd64.deb
-----> Installing libmagic-dev_1%3a5.32-2ubuntu0.1_amd64.deb
But the application still fails with the same error:
+ pip install -r requirements-test.txt
Requirement already satisfied: coverage==4.5.1 in ./.heroku/python/lib/python3.6/site-packages (from -r requirements-test.txt (line 1))
Requirement already satisfied: selenium==3.141.0 in ./.heroku/python/lib/python3.6/site-packages (from -r requirements-test.txt (line 2))
Requirement already satisfied: urllib3 in ./.heroku/python/lib/python3.6/site-packages (from selenium==3.141.0->-r requirements-test.txt (line 2))
You are using pip version 9.0.2, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
+ python manage.py collectstatic --no-input
Traceback (most recent call last):
File "manage.py", line 20, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 120, in populate
app_config.ready()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/core/admin.py", line 8, in <module>
from .forms import CrmDataUploadForm
File "/app/core/forms.py", line 3, in <module>
from magic import magic
ImportError: cannot import name 'magic'
Any ideas how to get python-magic working on Heroku?
The correct way to import the magic module is:
import magic
not
from magic import magic
python-magic just provides a magic module and python-magic-bin does the same. The problem is that python-magic-bin has a package called magic that imports the module magic.magic, which is sort-of like an internal detail, hence, the latter example works in python-magic-bin but not python-magic.
From the python-magic documentation:
>>> import magic
>>> magic.from_file("testdata/test.pdf")
'PDF document, version 1.2'
>>> magic.from_buffer(open("testdata/test.pdf").read(1024))
'PDF document, version 1.2'
>>> magic.from_file("testdata/test.pdf", mime=True)
'application/pdf'

Django INSTALLED_APPS not installed and preventing makemigrations

I recently pulled a repo from GitHub to get a local copy on my machine. The backend uses Django, and I was working on updating some models. Since I changed some models I wanted to run ./manage.py makemigrations. At first there was an issue with python2 vs python3, so I changed the #!/usr/bin/env python to #!/usr/bin/env python3. Then when I ran makemigrations, I get this:
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'autofixture'
Looking a bit further, I found out that this is because my settings.py file has autofixture, bootstrap3, and formtools in INSTALLED_APPS, but somehow my machine doesn't have those. I've tried to pip install all of them but the names autofixture, bootstrap3, and formtools aren't found in pip.
They are in pip, albeit not in those names; they are django-autofixture, django-bootstrap3 and django-formtools respectively.
So you can install them by typing:
pip install django-autofixture django-bootstrap3 django-formtools
Edit: Use pip3 instead of pip when using python3
pip3 install django-autofixture django-bootstrap3 django-formtools

Categories