Missing Python Packaging Tools on Python Interpreter - Django - python

I've been working on a basic Django project and I deployed it to AWS Elastic Beanstalk. I'm not sure if that's causing this, but I'm just telling you this so that you know what I might have been done with my project. Then, my python project interpreter got kinda messy and when I try to run the application it started to give me some errors about missing packages. After that, I checked my project interpreter, and it was like this:
Then, I tried to install the required packages using PyCharm, however, it kept giving me the error below. I also tried to build some of those packages manually, like Django, on my own terminal but the error was same. Further, I was able to install packages on other python versions on my mac, which sorta tells I might have messed my default python interpreter somehow.
40:357: execution error: Traceback (most recent call last): File
"/var/folders/f1/k7c234sx5fn9j84yt130_znr0000gn/T/tmp2zDEZTpycharm-management/pip-9.0.1/setup.py",
line 6, in
from setuptools import setup, find_packages File "/Users/bkaankuguoglu/Library/Python/2.7/lib/python/site-packages/setuptools/init.py",
line 12, in
import setuptools.version File "/Users/bkaankuguoglu/Library/Python/2.7/lib/python/site-packages/setuptools/version.py",
line 1, in
import pkg_resources File "/Users/bkaankuguoglu/Library/Python/2.7/lib/python/site-packages/pkg_resources/init.py",
line 72, in
import packaging.requirements File "/Users/bkaankuguoglu/Library/Python/2.7/lib/python/site-packages/packaging/requirements.py",
line 59, in
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker") TypeError: call() takes exactly 2 arguments (1 given) (1)
I'd really appreciate any help here and please ask me if any extra detail is needed to answer this question before downvoting.

pip install setuptools==33.1.1

Related

I cannot import libraries into python despite repeatedly installing them

I am struggling to install and import python libraries into my programs. originally I was using pydev but I kept getting messages like:
Traceback (most recent call last): File "C:\Users\satur\eclipse-workspace\DMD experimental\Main.py", line 11, in <module> from matplotlib import pyplot as plot ModuleNotFoundError: No module named 'matplotlib'
I installed matplotlib using py -m pip install matplotlib which produced a few messages like this.
WARNING: The script f2py.exe is installed in 'C:\Users\satur\AppData\Local\Programs\Python\Python310\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The scripts fonttools.exe, pyftmerge.exe, pyftsubset.exe and ttx.exe are installed in 'C:\Users\satur\AppData \Local\Programs\Python\Python310\Scripts' which is not on PATH.
I was unsure what this meant so I tried running my program again and got the module not found error again.
being unable to resolve the issue I moved over to spyder because it came with many of the libraries I wanted thus avoiding the issue. however, as soon as I tried to import and install libraries not included with spyder I encountered the module not found error and a similar warning about the path. I added the paths mentioned in the warning to the PATH in spyder now when I run my code get this error message:
runfile('C:/Users/satur/.spyder-py3/proper orthogonal decomposition/dynamic mode decomposition experimental driver.py', wdir='C:/Users/satur/.spyder-py3/proper orthogonal decomposition')
Traceback (most recent call last):
File "C:\Users\satur\AppData\Local\Programs\Spyder\pkgs\spyder_kernels\py3compat.py", line 356, in compat_exec
exec(code, globals, locals)
File "c:\users\satur\.spyder-py3\proper orthogonal decomposition\dynamic mode decomposition experimental driver.py", line 13, in <module>
import mat73
File "C:\Users\satur\AppData\Local\Programs\Python\Python310\Lib\site-packages\mat73\__init__.py", line 11, in <module>
import h5py
File "C:\Users\satur\AppData\Local\Programs\Python\Python310\Lib\site-packages\h5py\__init__.py", line 25, in <module>
from . import _errors
ImportError: cannot import name '_errors' from partially initialized module 'h5py' (most likely due to a circular import) (C:\Users\satur\AppData\Local\Programs\Python\Python310\Lib\site-packages\h5py\__init__.py)
I did some looking around and found this
https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder#installing-packages-into-the-same-environment-as-spyder
I followed what instructions I understood
import sys; sys.executable
Out[50]: 'C:\\Users\\satur\\AppData\\Local\\Programs\\Spyder\\Python\\python.exe'
which is different from what I get when I run it in command prompt or in the pydev terminal both of which give me
C:\Users\satur\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe
when i go to C:\Users\satur\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\ I see: 3 versions of idel, 3 versions of pip, and 6 versions of python.
I am deeply confused. I want to install and import libraries into my python programs. I want to be able to run my programs in either (or for that matter any) ide. I seem to be hitting the very similar issues in both. every tutorial I have found online describes the steps to take to do this but not what they are or why I am doing them none of them seem to work and the more times I try to install things the more confused I get.
could someone please explain: how to install and import libraries into a python program. what python is doing when I install things and try to import them. and why both IDEs have similar but different errors.

Syntax Error When Trying to Open Downloaded Django Application

I am trying to work on a Django application that I downloaded from bitbucket which uses Python2-based code. Previously, Python 3.6 and Django 2.0 was on my system, so I downgraded to Python 2.7 and Django 1.11 to try to get it to work.
When I go to the project directory and type in "python manage.py runserver," I get a syntax error (this is a shortened version of it, hence the dots):
Unhandled exception in thread started by <function wrapper at 0x0000000006A0A358>
Traceback (most recent call last):
File "C:\Users\M\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
.
.
.
File "C:\Users\M\Anaconda3\lib\site-packages\django\contrib\admindocs\urls.py", line 2, in <module>
from django.contrib.admindocs import views
File "C:\Users\M\Anaconda3\lib\site-packages\django\contrib\admindocs\views.py", line 9, in <module>
from django.contrib.admindocs import utils
File "C:\Users\M\Anaconda3\lib\site-packages\django\contrib\admindocs\utils.py", line 12, in <module>
import docutils.core
File "C:\Users\M\Anaconda3\lib\site-packages\docutils\core.py", line 246
print('\n::: Runtime settings:', file=self._stderr)
^
SyntaxError: invalid syntax
If you have a solution to this problem, please let me know.
As said by #emi, you want to use virtualenv. It's a great tool that allows you to create an isolated virtual environment for each Python project. Each virtual environment can have its own version of every dependency.
On Windows, I recommend using it alongside virtualenvwrapper, witch is is just a very thin wrapper with some higher level commands.
It seems your Python installation is broken so uninstall every version of Python you have, reinstall Python 2 and follow along creating a virtualenv for your project (and for every new one you start). If you need you can install Python 3 in the future as well without messing with you previous envs.

Ckan install module missing error

I am attempting to install ckan on my system and I'm following the install from package directions (http://docs.ckan.org/en/latest/maintaining/installing/install-from-package.html). All the dependencies were installed correctly and the ckan package itself downloaded without error. When I went to run the install I got a module missing error for what to me looks like a trivial python module that should be there.
jeremy#jeremy-HP-ProBook-4530s:~$ sudo dpkg -i python-ckan_2.5-trusty_amd64.deb
[sudo] password for jeremy:
(Reading database ... 214293 files and directories currently installed.)
Preparing to unpack python-ckan_2.5-trusty_amd64.deb ...
Unpacking python-ckan (2.5.1-trusty1) over (2.5.1-trusty1) ...
Setting up python-ckan (2.5.1-trusty1) ...
Traceback (most recent call last):
File "/usr/lib/ckan/default/bin/paster", line 7, in <module>
from paste.script.command import run
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 3, in <module>
import pkg_resources
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 36, in <module>
import plistlib
File "/usr/lib/python2.7/plistlib.py", line 62, in <module>
import datetime
ImportError: No module named datetime
/var/lib/dpkg/info/python-ckan.postinst: line 18: initctl: command not found
Site datapusher already enabled
I've confirmed that datetime is installed with a quick python -c 'import datetime' run. At this point I have done a little bit of digging and haven't been able to find anywhere else where this is duplicated nor exactly how to resolve this. Any help or advice is greatly appreciated.
Looking around for the error from plistlib it looks like the same error affecting https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1368144
Unfortunately I'm not sure how this would have come about. I'll continue digging and see if I can find out more, but it isn't anything I've seen before but it definitely appears virtualenv related.

Error Importing SHTOOLS Python Package

I am trying to import the spherical harmonic toolbox (SHTOOLS) in python. I have the files downloaded and unzipped and am using RedHat.
I added the package's path to my python system path and when I go to import the package, I get this error:
>>import pyshtools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pyshtools/__init__.py", line 49, in <module>
load_documentation()
File "pyshtools/__init__.py", line 27, in load_documentation
from . import _SHTOOLS
ImportError: cannot import name _SHTOOLS
I can not seem to figure out what the issue is. I checked that the path to this folder was actually added to the system path and it was.
Is this an issue on my end? Or is it possible that I have something downloaded incorrectly? If so, how would I go about fixing this issue?
The SHTOOLS package needs to be built with make first to compile the Fortran libraries. The wiki on Github gives directions on which libraries are required - libblas-dev, liblapack-dev, g++, gfortran, and libfftw3-dev (these are the Ubuntu packages, they may have slightly different names on Redhat). Once these are installed, you need to run make, then sudo make all to install the Fortran and Python components. The Makefile has a lot of good comments in it, I'd recommend reading through it before running make.

Dreamhost - ImportError: No module named _weakrefset

Dreamhost upgraded a number of servers this weekend, including the one I was on. It broke my configuration, so as recommended I attempted to delete the virtual environment it was running on and attempted to re-set it up. However, when I try to navigate to the site, I get this:
Traceback (most recent call last):
File "/home/thesp/mysite.com/env/lib/python2.7/site-packages/site.py", line 74, in <module>
__boot()
File "/home/thesp/mysite.com/env/lib/python2.7/site-packages/site.py", line 2, in __boot
import sys, os, os.path
File "/home/thesp/lib/python2.7/os.py", line 400, in <module>
import UserDict
File "/home/thesp/lib/python2.7/UserDict.py", line 83, in <module>
import _abcoll
File "/home/thesp/lib/python2.7/_abcoll.py", line 11, in <module>
from abc import ABCMeta, abstractmethod
File "/home/thesp/lib/python2.7/abc.py", line 8, in <module>
from _weakrefset import WeakSet
ImportError: No module named _weakrefset
I've got Python 2.7.8 installed and running, and from shell access, both in and out of my virtual environment when I run Python, I'm pulling up the correct version (which is different from the native version installed, so it's finding my setup). Other posts which reference this error message seem to think it's a problem with not having an upgraded version of virtualenv, but its version is higher than the troublesome version. (I'm running 1.11.6.)
Weirder still, I can shell into Python, type from _weakrefset import WeakSet, and I don't get import errors. I'm running Django 1.6 and I can python manage.py runserver with no errors, but the web server is throwing up before it ever sees Django.
In the traceback, the first two lines are pulling from my virtual environment, but the remaining ones don't seem to be, and I have no idea why, or even if that's relevant.
Any advice on what I should do next? I've about pulled my hair out on this one! I can post any additional information that would help troubleshoot. Thanks!
Well, I feel silly now. I went to the /home/thesp/lib/python2.7/ directory and downloaded _weakrefset.py, like so:
wget http://svn.python.org/projects/python/trunk/Lib/_weakrefset.py
...and now everything seems to be running fine. There was a _weakrefset.pyo file in the directory, so I'm not sure why _weakrefset.py never made it in, but this seems to have done the trick.
Now, that doesn't solve the mystery of why the stack trace switches directories like it does, but it's running now, so I'll take it for now!

Categories