I have Anaconda 32-bit Python 3.7.3 on Windows 10.
The library is written in C++ and so I have Microsoft Visual C++ 2017 (15.8) loaded too.
Problem I'm having is I get this error after running 'python setup.py install' whose output is in the attached file.
(C:\Users\david.callahan\AppData\Local\Continuum\anaconda32bit) C:\Users\david.callahan\AppData\Local\Continuum\anaconda32bit\Lib\site-packages\vnpy\python>python Python 3.7.3 (default, Apr 24 2019, 13:20:13) [MSC v.1915 32 bit (Intel)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information.
from vnpy import * Traceback (most recent call last): File "C:\Users\david.callahan\AppData\Local\Continuum\anaconda32bit\Lib\site-packages\vnpy\python\vnpy\libvncxx.py", line 18, in swig_import_helper return importlib.import_module(mname) File "C:\Users\david.callahan\AppData\Local\Continuum\anaconda32bit\lib\importlib__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'vnpy._libvncxx'
Not sure why it's not finding that library.
Related
This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed 1 year ago.
I'm trying to write a small script to manage my Binance account and I have an issue with a library.
I've installed the library "binance_f" from this repository https://github.com/Binance-docs/Binance_Futures_python
The library is correctly installed on default system env, and in the venv I created.
List from system env
List from venv
I can run my script from python3.8 (system or venv) console but I can't run it from pycharm.
From venv:
(venv) herve#neon-herve:~/PycharmProjects/Script-Discord-Futures$ python3.8
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import binance_f
>>> binance_f.__file__
'/home/herve/PycharmProjects/Script-Discord-Futures/venv/lib/python3.8/site-packages/binance_f/__init__.py'
>>>
From system env:
herve#neon-herve:/usr/lib/python3/dist-packages/Binance_Futures_python-master$ python3.8
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import binance_f
>>> binance_f.__file__
'/usr/lib/python3/dist-packages/Binance_Futures_python-master/binance_f/__init__.py'
I tried to use venv or system env with my PyCharm project but it failed.
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/herve/PycharmProjects/Script-Discord-Futures/binance_functions.py", line 8, in <module>
import binance_f
ModuleNotFoundError: No module named 'binance_f'
This is the interpreter in PyCharm:
System interpreter in PyCharm
Venv interpreter in PyCharm
In Pycharm, I tried to manually add the library but I have an error message. (I added the repository, and tried to install "binance_f".
Pycharm error
I really need to use PyCharm for the debug function !
Thanks a lot for your help.
So as it was clear the issue came from PyCharm I started to check all option available. I found an option in the execution configuration:
Solution
I just force PyCharm to run my script in Python Console !
Thanks to all for your help.
I'm trying to install TensorFlow for python (3.7) using anaconda.
I've installed the Cuda 10.2 and the matching cndd and installed it in a virtual environment:
pip install tensorflow==2.1.0
The command ran without any errors, but when i try to import it in python I get:
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\abual\Anaconda3\envs\ml1\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
from tensorflow_core import *
File "C:\Users\abual\Anaconda3\envs\ml1\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 959, in _find_and_load_unlocked
File "C:\Users\abual\Anaconda3\envs\ml1\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "C:\Users\abual\Anaconda3\envs\ml1\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "C:\Users\abual\Anaconda3\envs\ml1\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\abual\Anaconda3\envs\ml1\lib\site-packages\tensorflow_core\python\__init__.py", line 47, in <module>
import numpy as np
File "C:\Users\abual\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\abual\AppData\Roaming\Python\Python37\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\abual\Anaconda3\envs\ml1\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
>>>
Can anyone help me solve it?
Thanks
On your 1st question
The problem might be installing 32 bit on a 64-bit machine., try installing a 64 bit TensorFlow version 2.x.
Kindly refer to the documentation here
On your 2nd question
The tf.Session() is on the version 1.x, you need to migrate it to 2.1.
You can read about migration here
Kindly refer to the sample code below
# Using the `close()` method.
sess = tf.compat.v1.Session()
sess.run(...)
sess.close()
I am new to Python and am trying to setup environment so I can use MS SQL. My simple python code fails on: import pyodbc with following error:
ImportError: DLL load failed while importing pyodbc: The specified module could not be found.
Background:
I installed Python 3.8.1 for windows 64-bit.
Installed pyodbc (pip install pyodbc) with no issue.
Installed Microsoft ODBC Driver 17 for SQL Server for Windows 64-bit
TRACE:
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "dbtest.py", line 10, in <module>
import pyodbc
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
File "<frozen importlib._bootstrap>", line 556, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1101, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed while importing pyodbc: The specified module could not be found.
I fixed my issue by downgrading pyodbc package from 4.0.28 to 4.0.27 and now it works.
(It's frustrating when newest packages don't work together)
I used a following command:
pip install --upgrade pyodbc==4.0.27
The root cause could be because your IDE (VS Code in many cases) has the wrong installation of Python installed. You may have to use some of the other fixes like deleting temp files, uninstalling/reinstalling PYODBC or downgrading.
If none of those work, you may have the wrong installation of Python selected in VS Code.
To change, go to VS Code and hit "Ctrl+Shift+P" then type "Python: S"
Select the python interpreter line and a the options will change to show you all the registered versions of Python installed. In my case I wanted the version I manually installed from Python in the root of my C drive. Selecting this version allowed my installation of PYODBC to be found and imported without further tweaking.
I successfully installed nltk and works fine in python 3.6.3. I have to run a file where nltk was imported and tensorflow too ,hence, i have to activate tensorflow.
HP-250-G5-Notebook-PC:~$ python
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>>
When I activate tensorflow seems to use python 3.5.2.
(tensorflow)HP-250-G5-Notebook-PC:~/AIG2018/Chatbot$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
When I look up for solutions this is what I tried but no positive results.
(tensorflow) country_boy#Shikongo-Veijo-HP-250-G5-Notebook-PC:~$ pip install nltk
Traceback (most recent call last):
File "/home/country_boy/tensorflow/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2927, in <module>
#_call_aside
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2913, in _call_aside
f(*args, **kwargs)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
add_activation_listener(lambda dist: dist.activate())
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 956, in subscribe
callback(dist)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2952, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2515, in activate
declare_namespace(pkg)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
_handle_ns(packageName, path_item)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2047, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
I think this has to do with pip. The question is how do i install nltk in python 3.5.2??? Or how to i make everything work??
I recently installed SPARK in my MAC computer using the following command:
brew install apache-spark
Now I tried to run
pyspark but it is showing me the following error.
pyspark
Python 3.6.0 |Anaconda custom (x86_64)| (default, Dec 23 2016, 13:19:00
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last)
File "/usr/local/Cellar/apache-spark/2.1.0/libexec/python/pyspark/shell.py", line 30, in <module>
import pyspark
File "/usr/local/Cellar/apache-spark/2.1.0/libexec/python/pyspark/__init__.py", line 44, in <module>
from pyspark.context import SparkContext
File "/usr/local/Cellar/apache-spark/2.1.0/libexec/python/pyspark/context.py", line 36, in <module>
from pyspark.java_gateway import launch_gateway
File "/usr/local/Cellar/apache-spark/2.1.0/libexec/python/pyspark/java_gateway.py", line 31, in <module>
from py4j.java_gateway import java_import, JavaGateway, GatewayClient
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
File "<frozen importlib._bootstrap>", line 616, in _load_backward_compatible
File "/usr/local/Cellar/apache-spark/2.1.0/libexec/python/lib/py4j-0.10.4-src.zip/py4j/java_gateway.py", line 18, in <module>
File "/Users/hellmaster/anaconda/lib/python3.6/pydoc.py", line 62, in <module>
import pkgutil
File "/Users/hellmaster/anaconda/lib/python3.6/pkgutil.py", line 22, in <module>
ModuleInfo = namedtuple('ModuleInfo', 'module_finder name ispkg')
File "/usr/local/Cellar/apache-spark/2.1.0/libexec/python/pyspark/serializers.py", line 393, in namedtuple
cls = _old_namedtuple(*args, **kwargs)
TypeError: namedtuple() missing 3 required keyword-only arguments: 'verbose', 'rename', and 'module'
How do I fix this issue?
This is because Spark 2.1.0 is incompatible with Python 3.6.
See also this question.