abhishek-ram / pyas2

This repo is no longer maintained and has been moved to https://github.com/abhishek-ram/django-pyas2
GNU General Public License v2.0
47 stars 23 forks source link

when installing pyas2 from pip installation steps fail at manage.py command #51

Closed DrewTittle closed 5 years ago

DrewTittle commented 5 years ago

I'm following the directions here:

https://pyas2.readthedocs.io/en/latest/installation.html

I'm on an Amazon Linux EC2 system. I am trying to run the pip install command in my activated python 2.7 virtualenv:

virtualenv -p `which python2.7` venv
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in /home/ec2-user/environment/pyas2_test/venv/bin/python2.7
Also creating executable in /home/ec2-user/environment/pyas2_test/venv/bin/python
Installing setuptools, pip, wheel...
done.

Then I activate the env and install with pip:

source venv/bin/activate

pip install pyas2
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pyas2
Collecting cherrypy<=8.9.1,>6 (from pyas2)
  Using cached https://files.pythonhosted.org/packages/9d/c2/8a19081b3ded7b5f497ba132055ba665188432be02512d80cd7ac93c86d6/CherryPy-8.9.1-py2.py3-none-any.whl
Collecting pyasn1 (from pyas2)
  Using cached https://files.pythonhosted.org/packages/7b/7c/c9386b82a25115cccf1903441bba3cbadcfae7b678a20167347fa8ded34c/pyasn1-0.4.5-py2.py3-none-any.whl
Collecting requests (from pyas2)
  Using cached https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl
Collecting m2crypto (from pyas2)
Collecting django<=1.10.6,>1.9 (from pyas2)
  Using cached https://files.pythonhosted.org/packages/b9/bb/723f78e6f6aea78590331eba4e42b8a09c33ce154204a942525a91101d0b/Django-1.10.6-py2.py3-none-any.whl
Collecting six (from cherrypy<=8.9.1,>6->pyas2)
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests->pyas2)
  Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.9,>=2.5 (from requests->pyas2)
  Using cached https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->pyas2)
  Using cached https://files.pythonhosted.org/packages/9f/e0/accfc1b56b57e9750eba272e24c4dddeac86852c2bebd1236674d7887e8a/certifi-2018.11.29-py2.py3-none-any.whl
Collecting urllib3<1.25,>=1.21.1 (from requests->pyas2)
  Using cached https://files.pythonhosted.org/packages/62/00/ee1d7de624db8ba7090d1226aebefab96a2c71cd5cfa7629d6ad3f61b79e/urllib3-1.24.1-py2.py3-none-any.whl
Collecting typing (from m2crypto->pyas2)
  Using cached https://files.pythonhosted.org/packages/cc/3e/29f92b7aeda5b078c86d14f550bf85cff809042e3429ace7af6193c3bc9f/typing-3.6.6-py2-none-any.whl
Installing collected packages: six, cherrypy, pyasn1, chardet, idna, certifi, urllib3, requests, typing, m2crypto, django, pyas2
Successfully installed certifi-2018.11.29 chardet-3.0.4 cherrypy-8.9.1 django-1.10.6 idna-2.8 m2crypto-0.31.0 pyas2-0.4.3 pyasn1-0.4.5 requests-2.21.0 six-1.12.0 typing-3.6.6 urllib3-1.24.1

I can see it successfully install pyas2, django and m2crypto but when I open the python shell and try an import of pyas2 I get:

python
Python 2.7.15 (default, Nov 28 2018, 22:38:08) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyas2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pyas2
>>> 

following the steps in the installation doc I can create the django project but when I try to run the manage.py migrate command I get the following error:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute
    django.setup()
  File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 94, in create
    module = import_module(entry)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named pyas2

Unwilling to be beaten I tried downloading the package from pypi and running the setup.py in the download:

https://pypi.org/project/pyAS2/#files

if I run it with the setup.py install --user command it seems to install successfully and I'm able to import pyas2 in the python shell.

I'm also able to continue the setup process and the python manage.py migrate command runs as you'd expect.

python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, pyas2, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying pyas2.0001_initial... OK
  Applying pyas2.0002_partner_compress... OK
  Applying pyas2.0003_auto_20150311_1141... OK
  Applying pyas2.0004_auto_20150311_1258... OK
  Applying pyas2.0005_message_compressed... OK
  Applying pyas2.0006_auto_20150313_0548... OK
  Applying pyas2.0007_auto_20150313_0707... OK
  Applying pyas2.0008_auto_20150317_0450... OK
  Applying pyas2.0009_auto_20150317_1324... OK
  Applying pyas2.0010_auto_20150416_0745... OK
  Applying pyas2.0011_auto_20150427_1029... OK
  Applying pyas2.0012_auto_20151006_0526... OK
  Applying pyas2.0013_auto_20160307_0233... OK
  Applying pyas2.0014_auto_20160420_0515... OK
  Applying pyas2.0015_auto_20160615_0409... OK
  Applying pyas2.0016_auto_20161004_0543... OK
  Applying pyas2.0017_auto_20170404_0730... OK
  Applying pyas2.0018_auto_20180109_0942... OK
  Applying pyas2.0019_auto_20180127_0509... OK
  Applying sessions.0001_initial... OK

I'm ok with this for the time being but I'm curious about why the pip install doesn't work. I'm not sure where the import issue is but I'll research more and see if I can find a fix. If someone else can think of another fix to allow me to install with pip so I can put this in my virtualenv I'd appreciate the help.

If it's something obvious I'm missing I'd be happy to update the documentation with details to get around it.

Thanks for this package by the way! I'm thrilled to start using it.

DrewTittle commented 5 years ago

I'm running this from an AWS EC2 Server which has a default .bashrc with:

alias python=python27

I created a virtualenv like this:

virtualenv venv --python=python27

If I look in the venv/bin folder I see a symlink for python2.7 and python2 but not one for python27. So that alias in the .bashrc was aliasing python to python27 which only existed under /usr/bin not in my venv. I assumed since python27 exists in the usr/bin folder it would get copied to the venv but it does not.

I'm used to changing that alias to python3 right away so I hadn't noticed this before.

What I still don't quite understand is why other packages like requests still seem to import normally when I ran python using the python27 alias and only pyas2 failed!

This works though, I can either change the alias to python2 or add a symlink from python27 to python in my venv/bin folder.