I am having trouble importing a library called pymssql.
I have read previous solutions regarding this issue on stack overflow. The following are the solutions that did not work:
Error importing pymssql
import pymssql Unicode DecodeError in windows 7
I am running a conda virtual environment with Python 3.7.9. The following is the output when I run python in the terminal.
Python 3.7.9 (default, Aug 31 2020, 07:22:35)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
So, this confirmed that I was using the correct Python version. Next, I tried to import a library called pymssql.
This looked like:
>>> import pymssql
This returned an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/anaconda3/envs/conda_env/lib/python3.7/site-packages/pymssql/__init__.py", line 3, in <module>
from ._pymssql import *
File "src/pymssql/_pymssql.pyx", line 1, in init pymssql._pymssql
ImportError: dlopen(/usr/local/anaconda3/envs/conda_env/lib/python3.7/site-packages/pymssql/_mssql.cpython-37m-darwin.so, 2): Symbol not found: _iconv
Referenced from: /usr/local/anaconda3/envs/conda_env/lib/python3.7/site-packages/pymssql/_mssql.cpython-37m-darwin.so
Expected in: flat namespace
in /usr/local/anaconda3/envs/conda_env/lib/python3.7/site-packages/pymssql/_mssql.cpython-37m-darwin.so
>>>
I have tried conda install pymssql and pip install pymssql. Neither of these solved the issue.
Related
When I try to import the MWE below from the Terminal in VSCode, I get
ModuleNotFoundError: No module named 'tqdm'
temp.py:
import tqdm
print('hello')
Here is my Terminal session:
(mainenv) Larrys-MBP-5:Desktop larry$ python3
Python 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:39:15)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import temp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/larry/Desktop/temp.py", line 1, in <module>
import tqdm
ModuleNotFoundError: No module named 'tqdm'
I'm using a conda environment called mainenv. I can confirm (via conda list) that tqdm is installed:
I can also confirm that VSCode is using mainenv as the interpreter:
I get the same error if I replace tqdm with other packages too, like jsonpickle and tabulate. But if I replace it with numpy or networkx, for example, it works fine.
What's going on here?
Did You Use Pip Or npm? When I try to use npm in vscode for python modules it doesn't work, it works for me when I use pip though.
As the title says, i can't import mysql.connector in python on Debian 9.13
This is what i did
# python
Python 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516] on
linux2 Type "help", "copyright", "credits" or "license" for more
information.
>>> import mysql.connector
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/__init__.py", line 53, in <module>
from .connection import MySQLConnection
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/connection.py", line 450
f"This connection is using {tls_version} which is now "
^
SyntaxError: invalid syntax
I tried installing, uninstalling and reinstalling mysql-connector, mysql-connector-python and mysql-connector-python-rf in Python2.7 and Python3
Before someone flags this question as duplicated, i already tried all the answers in this posts:
This connection is using {tls_version} which is now
Unresolved import mysql.connector PYTHON
import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package
mysql connector not found
ImportError: No module named 'MySQL'
This connection is using {tls_version} which is now, unable to deploy Flask application on Linux
Any help would be appreciated.
As #TimRoberts and #Dhivakar Chelladurai said in te comments, the solution is to find a version of MySQL-Connector-Python for Python2 or Python3.5 max as this is the last version that Debian 9 has for Python3.
Download:
wget https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python_2.1.8-1debian9_all.deb
Install:
sudo dpkg -i mysql-connector-python_2.1.8-1debian9_all.deb
Thats it!
I've noticed that while I can point my environment variables to Anaconda's Python interpreter, I don't get a fully working Python environment when I execute python in the command prompt. Python will still launch, but many of its packages are "broken."
PROBLEM:
Anaconda's Python interpreter does launch when called from command prompt, but it isn't able to import some of its packages (numpy being one of them used in this example).
EXAMPLE(WINDOWS CMD):
> where python
C:\Anaconda3\python.exe
Great, python calls the right interpreter. Let's go in there and import numpy!
> python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified module could not be found.
This is weird. Let's try launching "Anaconda Prompt", which appears to just be an activated Anaconda environment.
>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
Everything works fine this way.
SUMMARY:
I'm expecting Anaconda's Python interpreter to launch from the command prompt and behave just the way it would if launched from within the Anaconda Prompt (which appears to just be a command prompt with an activated Anaconda environment).
What can I do to be able to get a fully working Anaconda Python interpreter by just launching python from the Window's command prompt? Maybe what I'm really asking is, what do I need to change in my environment variables to ensure that the Anaconda environment is activated when I call on python from the command prompt?
Activating a conda environment can also change the PATH. I suggest you compare PATH before and after activating the environment.
Any new solution for this. I am unable to from ciscoconfparse import CiscoConfParse
I tried several versions of ciscoconfparse in python3 usin gpowershell in windows10.
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ciscoconfparse import CiscoConfParse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python3\lib\site-packages\ciscoconfparse\__init__.py", line 1, in <module>
from .ciscoconfparse import *
File "C:\Python3\lib\site-packages\ciscoconfparse\ciscoconfparse.py", line 4018
^
SyntaxError: invalid syntax
I still have not found a version that will let me import the module.
I browsed through several links here..but did not find an answer. The closest issue to mine is:
ciscoconfparse in Python 3.4 module doesn't import correctly
but not answer.
Any new info?
Thanks
I have reproduced the bug where Win10 and Python 3.7.0 cause problems.
FWIW, if you completely uninstall Python 3.7.0 (including manually deleting your Windows installation directory tree), then install Python 3.7.1, you should not have this problem with Windows 10.
I'm running OSX ElCapitan and I've brew install easysnmp... nevertheless, when I try to import it on python, I get the following error:
Python 2.7.12 (default, Jun 29 2016, 14:05:02)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from easysnmp import Session
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/easysnmp/__init__.py", line 1, in <module>
from .easy import ( # noqa
File "/usr/local/lib/python2.7/site-packages/easysnmp/easy.py", line 3, in <module>
from .session import Session
File "/usr/local/lib/python2.7/site-packages/easysnmp/session.py", line 8, in <module>
from . import interface
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/easysnmp/interface.so, 2): Symbol not found: _netsnmp_transport_config_compare
Referenced from: /usr/local/lib/python2.7/site-packages/easysnmp/interface.so
Expected in: flat namespace
in /usr/local/lib/python2.7/site-packages/easysnmp/interface.so
easysnmp sites state that it requires net-snmp 5.7 although el capitan is shipped with 5.6... so I've "brew installed" snmp-get 5.7.
Brew doesn't change the symlinks so I'm assuming python is still looking at version 5.6.
Install output :
==> make
==> make install
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.
OS X already provides this software and installing another version in
the parallel can cause all kinds of trouble.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/net-snmp/lib
CPPFLAGS: -I/usr/local/opt/net-snmp/include
==> Summary
🍺 /usr/local/Cellar/net-snmp/5.7.3: 538 files, 12.8M, built in 4 minutes 34 seconds