It's worth noting that I'm using a custom buildpack to enable coffeescript compilation with node.js.
After a change that included a migration, I got the below error upon running the migration
Running `./manage.py migrate talent` attached to terminal... up, run.3366
Traceback (most recent call last):
File "./manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/app/lib/python2.7/site-packages/django/core/management/__init__.py", line 1, in <module>
import collections
File "/usr/local/lib/python2.7/collections.py", line 8, in <module>
from _collections import deque, defaultdict
ImportError: No module named _collections
After poking around a bit in a heroku run bash shell session I found that the same error could be triggered by opening a python repl and running import collections.
Further poking revealed that the error could be suppressed by adding /usr/local/lib/python2.7/:/usr/local/lib/python2.7/lib-dynload/ to $PYTHONPATH. I first tried to to this in the bin/release file of the buildpack, but I also had a PYTHONPATH config variable which apparently overrides the buildpack setting of the environment (as it probably should).
Anyway fixing the $PYTHONPATH made everything work again, but this feels awkward, like a symptom that something else has gone wrong. Hopefully someone with more Heroku knowledge than me can shed some light.
Related
I am trying to run my python app on my website, and so I've created a virtual environment for all of the packages, and I've correctly installed all of the packages I need. When I check on the file path to my installed packages, they are all pointing to the correct path, and when I got to my site-packages file that they point to, they are all there.
However,
Every time I try to run my app, I get this:
stdin: is not a tty
Traceback (most recent call last):
File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 369, in <module>
app_module = load_app()
File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 76, in load_app
return imp.load_source('passenger_wsgi', startup_file)
File "/home/dsmproto/testblockchain/passenger_wsgi.py", line 1, in <module>
import main as application
File "/home/dsmproto/testblockchain/main.py", line 2, in <module>
from wallet import wallet
File "/home/dsmproto/testblockchain/wallet.py", line 1, in <module>
from Cryptodome.PublicKey import RSA
ImportError: No module named Cryptodome.PublicKey
I know that the module is there, but for some reason it is still saying there's no module.
Is there a command I can use in my SSH to check where my app is looking for modules?
All of the modules I have installed are installed correctly. Furthermore, when I open the SSH and run python commands in the terminal, they are able to import all of the modules without any issues.
So how come my app can't find these modules? Is there a way to check to make sure they are looking in the right place?
Thanks in advance for the help
EDIT:
I ran a script in python to look at the sys.path and got this:
/opt/alt/python38/lib64/python38.zip
/opt/alt/python38/lib64/python3.8
/opt/alt/python38/lib64/python3.8/lib-dynload
/home/dsmproto/virtualenv/testblockchain/3.8/lib64/python3.8/site-packages
/home/dsmproto/virtualenv/testblockchain/3.8/lib/python3.8/site-packages
Those are the correct folders that my packages are installed in, yet when I try to run my app, it still says it can't find them.
Working on code that SSH's into terminal on an external device. This morning the code was able to do so. Then I updated Windows because I had put it off for a while. This was the only thing I did that I could think of may have had an effect.
I now run into a ModuleNotFoundError.
I tried updating pip, uninstalling and reinstalling ssh2-python. I changed python37 folder to read/write. Tried locating the module in python37/Lib/site-packages but not really sure what I'm looking for
SSH's into address' terminal
import socket
from ssh2.session import Session
Expected:
input for ip address
Result:
Traceback (most recent call last):
File "C:/Users/louis/Desktop/ssh2.py", line 4, in <module>
from ssh2.session import Session
File "C:\Users\louis\Desktop\ssh2.py", line 4, in <module>
from ssh2.session import Session
ModuleNotFoundError: No module named 'ssh2.session'; 'ssh2' is not a package
I had named a file in the same directory ssh2. Python loaded that instead of the module. Simply renamed the file to anything else and python was able to find the ssh2 module.
Good day,
I recently tried to upgrade to Python 3.6.1 by building from source, and I've had a few issues.The first of which had to do with the $PYTHONHOME environment variable, which I have now (seemingly) solved, whereas the second - and most persistent - has to do with me not being able to access many modules.
For instance, when I launch the python3 interpreter, I immediately encounter an error that states:
Traceback (most recent call last): File "/etc/pythonstart", line 7,
in
import readline ModuleNotFoundError: No module named 'readline'
Similar errors occur with other modules that are imported by other scripts, such as 'encodings'
ImportError: No module named 'encodings'
and '_socket'
ModuleNotFoundError: No module named '_socket'
I'm not used to building from source, so I just used the instructions in the readme file that comes with the Python 3.6.1 tar ball, without much understanding of what's going on. I performed this procedure over and over again, (hopefully that didn't add to the problems), and here's the latest error output from the make test command:
Traceback (most recent call last): File
"./Tools/scripts/run_tests.py", line 12, in
import test.support
File "/usr/local/lib/python3.6/test/support/init.py", line 15, in
import logging.handlers
File "/usr/local/lib/python3.6/logging/handlers.py", line 26, in
import logging, socket, os, pickle, struct, time, re
File "/usr/local/lib/python3.6/socket.py", line 49, in
import _socket ModuleNotFoundError: No module named '_socket'
Makefile:1018: recipe for target 'test' failed make: *** [test] Error 1
I've searched all over the web frantically and I can't seem to find anything that really captures my problem, as the many other problems I've seen often involve people not being able to access only one module, or the solutions provided are extremely specific and seem difficult to generalise from (such as solutions that make use of lengthy Debian-based commands). I sincerely apologise if there are general solutions to this problem that I just haven't found.
Additionally, when I try to launch the Python 2 interpreter, I just get this error (and it fails completely):
ImportError: No module named site
My system information:
OS: Opensuse Leap 42.2
Previous Python3 version: 3.4.5 Current
Python3 version: 3.6.1
Your help with this matter would be greatly, greatly appreciated!
I'm trying to use MySQLdb and when I try to import it I get the following error. Any thoughts? I'm currently using an ubuntu instance on aws.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
>>>
Is libmysqlclient-dev installed? Package might not be exact, but thats the general idea.
Is this comment thread of any help?
Try updating /etc/ld.so.conf so as to include the directory in which you've installed this.
After struggling with this same issue myself (on the AWS Linux I AMI), I found the answer
here:
While the comment thread already posted was helpful, Apache was clearing my environment variables, so setting LD_RUN_PATH and/or LD_LIBRARY_PATH was not effective.
What ended up working was adding a new include statement to /etc/ld.so.conf and running ldconfig.
I have installed CherryPy 3.1.0,. Here is what happens when I try to run tutorial 9:
$ cd /Library/Python/2.5/site-packages/cherrypy/tutorial/
$ python tut09_files.py
Traceback (most recent call last):
File "tut09_files.py", line 48, in <module>
from cherrypy.lib import static
ImportError: cannot import name static
The previous line in the file:
import cherrypy
passes without error, so it appears that it can find cherrypy on the path. What am I missing?
This works for me, and I'm also using CherryPy 3.1.0, so I'm not sure what to tell you.
Look in your /Library/Python/2.5/site-packages/cherrypy/lib directory for a file named static.py; if this file exists then I'm not sure what to tell you. If it doesn't then something has happened to your CherryPy and I'd advise you to reinstall. If it does then you should check the value of sys.path to make sure it's detecting the right version of CherryPy.
You can also try running the python interpreter on the command line and then doing a from cherrypy.lib import static to see if you get the same result.
I had an old CherryPy-2.3.0-py2.5.egg file in my site-packages. After removing the old .egg I could run the tutorial.