I'm trying to fix a little SublimeText2 plugin. the problem seems to be (from SublimeText python console) to be an import error:
Traceback (most recent call last):
File ".\sublime_plugin.py", line 62, in reload_plugin
File ".\rtl.py", line 4, in <module>
from algorithm import get_display
File "lang\algorithm.py", line 20, in <module>
from unicodedata import bidirectional, mirrored
ImportError: No module named unicodedata
since unicodedata is the standard python library, I tried to import it directly in the console and got the same import error. I figured this is because sublimetext isn't using the system installed python version (I'm using python2.7 in a windows machine) but It's own bundled 2.6 python which doesn't bundle the whole standard library.
when I try the import from my usual python interpreter everything works fine.
I tried adding a .pth file that points to "c:\python27\lib" and site-packages etc. which didn't help. adding directly to the path like this:
sys.path.append(c:\\Python27\\lib)
didn't help either. also tried to tweaked my user setting file to include:
{
"PATH": "C:\\Python27;c:\\Python27\\Scripts",
"PYTHONPATH": "C:\\Python27\\Lib;C:\\Python27\\Lib\\site-packages;C:\\Python27\\DLLs"
}
my question divides into two:
how to solve this problem specifically on my dev computer
what is the right way to solve this universally for people trying to install the plugin. making the plugin dynamically aware of the default python installation and adding it to the path.
Also, the strangest thing: The main SublimeText folder in program files actually has the unicodedata.pyd file in it. so I can't figure what the problem is!
Looks like this might be a ST2 bug rather than something you're doing wrong:
http://www.sublimetext.com/forum/viewtopic.php?f=3&t=3462
Related
When I run some commands, which work, for example neofetch, it gives me a Python error.
username#host:~$ as
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in <module>
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
It does that whenever I type an invalid command. This started happening after I installed Python 3.9. I am running Kubuntu with Python 3.10 installed by default.
Modern Linux distributions tend to use a lot of python scripts for internal use; for this reason python gets installed with a plethora of libraries.
The error you are getting is because you replaced that fairly complete system python with a version of your own choosing without providing all the libraries the original came with.
The error you see is emitted by /usr/lib/command-not-found, a script using python3 as found in the system path.
I strongly recommend that you re-install the original python packages and use e.g. anaconda for your specific python needs.
The main takeaway from this is:
DON'T MESS WITH THE SYSTEM PYTHON.
try to find which python are you using using which python and uninstall the first python interpreter it finds.
First and foremost, I'm not a very experienced wine user.
Onto the problem. I want to run a Windows executable which in some way or another launches some sort of a python script (presumably, for authorization purposes). In this script, as evident from the error message, an import of "ssl" is present and it fails:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named ssl
I have found that ssl is by default bundled with python 2.6+. I have also found that installing/uninstalling any versions of python inside wine does not fix the issue. Furthermore, I can import ssl inside of wineconsole successfully and also on my linux installation with both python2 and python3.
I don't know how to solve this, but I have a guess that wine pulls python modules from somewhere else, although I haven't been able to find where from exactly and why.
I am trying to run import pandas code via Anacondas' python executable, in sublime text 3, and receive the following error message...
Traceback (most recent call last):
File "C:\<dir>\<python_file>.py", line 1, in <module>
import pandas as pd
File "C:\Users\<>\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
I can import pandas, and run other code when using spyder, but am struggling to get the environment setup in sublime. I have followed the two tutorials below, however I'm not having any luck.
Using Anaconda On Sublime Text (without installing any package)
Anaconda Documentation: Sublime text
any suggestions/advice is much appreciated!
import pandas as pd
It is a bit strange you can import pandas in Spydrr and get an error in Sublime. I cannot give a do-this answer, but I can suggest a review of concepts that you use for diagnostics:
Sublime and Spider are text editors, they are to handle code themselves, but invoke python interpreter that is already installed on the system (eg Anaconda)
sometimes you several python interpreters installed, would need to find out which has a precedence to appear in your path search
same interpreter may work with different virtual environments (package sets), controlled by venv.
From your disgnostic message hard to tell which situation you are in. When in doubt, try play on the command line to run the python.exe and explore your PATH variable.
Hope it helps.
I'm rather new to using python and haven't done really anything to configure python. my professor gave us an autograder.py file that checks our python code for correctness. the autograder.py file imports a file called grader.py which then imports something known as cgi (import cgi). inside this cgi file located at '/usr/lib/python2.7/cgi.py' there is a line of code that says
from operator import attrgetter
this is where the problem occurs. i recieve the following error
Traceback (most recent call last):
File "autograder.py", line 12, in <module>
import grading
File "/home/ggkfox/Documents/164-CSCI/1-Assignment/tutorial/grading.py", line 13, in <module>
import cgi
File "/usr/lib/python2.7/cgi.py", line 37, in <module>
from operator import attrgetter
ImportError: No module named operator
it is my understanding that the operator module should be built in (according to other stack overflow posts). this error only occurs when i use python2.7.12 (as opposed to python3.5). i have had a simular issue importing Tkinter in 2.7 aswell.
also i want to say that i have tried uninstalling python using:
sudo apt-get purge python2.7
but it wont even uninstall for me to even attempt to reinstall. im not using any pipenv or desktopenv.
i dont know what else to say, im very new to python coding.
It is almost a necessity to use a virtualenv for each python project.
A virtualenv creates a dedicated python environment and it saves you from a lot of 'operating system' related issues.
Here, you can find some virtualenv solutions compatible with all Python versions, along with the official python 3.6.4 documentation.
So I need some modules for a project and after trying a lot of things and googling a lot of things I still can't get it to work. I used this code to test if the module was working:
import sys
sys.path.append('c:\users\my name\anaconda2\lib\site-packages')
import numpy
x = randn(100,100)
And I got this error:
Traceback (most recent call last):
File "C:\Users\My Name\Desktop\test.py", line 3, in
import numpy
ImportError: No module named numpy
Any idea why I'm doing wrong?
You can try two things:
1) which python
And see what python you are using. You may be still pointing to old python the system has. In that case add ~/anaconda2/bin to $PATH environment variable.
2) sys.path.append('c:\users\my_name\anaconda2\lib\python2.x\site-packages')
Usually anaconda library is installed under lib\pythonx.x(the correct python version number)\site-packages. So change that.
If none of the above worked, then just do clean install from scratch all over again.