I have installed with pip several packages (numpy/pandas/blpapi/pyarrow). I work with a Windows 64-bit machine, python3.6 in a sublime environment.
While all packages are shown as correctly imported in the command prompt, some packages are not found by my sublime scripts.
To try and remedy this problem, I used sys.path.insert and changed the names of my scripts, to no avail. The traceback below describes what I'm seeing:
Code in Command Prompt:
>>> import pyarrow
>>> import pandas
>>>
Code in Sublime (better_name.py):
print('Hi')
import numpy
import pandas
Output of better_name.py:
Hi
Traceback (most recent call last):
File "C:\Users\Documents\better_name.py", line 4, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
Obtaining the paths in Command Prompt:
>>> import os
>>> import numpy
>>> path = os.path.dirname(numpy.__file__)
>>> print(path)
C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy
>>> import pandas
>>> path = os.path.dirname(pandas.__file__)
>>> print(path)
C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas
Trying to use sys.path.insert :
print('Hi')
import sys
import numpy
import os
sys.path.insert(1, r"C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas")
Output:
C:\Users\Documents>better_name.py
Hi
Traceback (most recent call last):
File "C:\Users\Documents\better_name.py", line 7, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
I get the same results whether I change the argument in sys.path.insert to 0.
The issue seems to be that your default version of python points to the 32-bit version - i.e. when you say python your windows system executes the 32 bit version.
One workaround is to specify the full path of your 64 bit version - i.e. launch your script as
C:\PATH\TO\64-BIT-VERSION\PYTHON.EXE your_script.py
from the command line.
The other option is to set your windows environment variables to point to the 64 bit version by default. This link should help
Related
This is the log I get when launching a pentesting tool:
Traceback (most recent call last):
File "web-brutator.py", line 7, in <module>
from lib.core.ArgumentsParser import ArgumentsParser
File "/home/pc/web-brutator/lib/core/__init__.py", line 3, in <module>
from .ArgumentsParser import *
File "/home/pc/web-brutator/lib/core/ArgumentsParser.py", line 9, in <module>
import lib.core.Globals as Globals
AttributeError: module 'lib' has no attribute 'core'
The ArgumentsParser.py, line 9:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import os
import re
from lib.core.Config import *
from lib.core.Utils import Utils, LineWrapRawTextHelpFormatter
import lib.core.Globals as Globals
class ArgumentsParser:
python3 --version
Python 3.6.9
Do I need to downgrade any Python module or reinstall any different version? It seems to me some kind of incompatibility.
It is solved using python3.8
I noticed after checking the python version that I have 3.6 in update-alternatives
I cannot import any python package when running python on Visual Studio code or on my Terminal. I can still do this if I were to code on a Jupyter notebook. However, when I tried other environment that doesn't use the notebook server. It returns me ModuleNotFound Error like this
Traceback (most recent call last):
File "/Users/truongminh/Desktop/DataScience/Datasets/CityU Text/test_PreprocessText.py", line 1, in <module>
import PreprocessText
File "/Users/truongminh/Desktop/DataScience/Datasets/CityU Text/PreprocessText.py", line 1, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Most of my packages was download via anaconda. I don't know if it might be the cause of this.
I just managed to get this figured out but i couldn't find a post about my specific problem so here it is.
I had installed numpy using
py -m pip install NumPy
I got the following error when I tried to import it
>>> import NumPy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'NumPy'
I solved my problem by unistalling NumPy and re-installing it with all LOWER-CASE LETTERS i.e.
py -m pip install numpy
Now I can import it with lower case letters
>>> import numpy
>>>
hope this can help someone else save an hour.
I want to use scikits.talkbox, but i get the following error while import scikits.talkbox.
Traceback (most recent call last):
File "/home/seref/Desktop/machine learning codes/MFCC/main.py", line 3, in
from scikits.talkbox.features.mfcc import mfcc
File "/usr/local/lib/python3.5/dist-packages/scikits/talkbox/init.py", line 3, in
from tools import *
ImportError: No module named 'tools'
code sample
import scipy.io.wavfile
from scikits.talkbox.features.mfcc import mfcc
sample_rate, X = scipy.io.wavfile.read("data/test_1.wav")
ceps, mspec, spec = mfcc(X)
I use following code when installing scikits.talkbox
sudo pip3 install scikits.talkbox
Operation system ubuntu 16.10
python interpreter 3.5.2+
If you want MFCCs in Python 3, librosa is probably the better library of your choice.
I have installed a python library in python3.3. When I run the interpreter in Dreampie, it can't find my newly-installed library, resulting in an error like:
>>> from bs4 import BeautifulSoup
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
from bs4 import BeautifulSoup
ImportError: No module named 'bs4'
This is a dreampie 1.2.1 bug. To work around it, under Edit | Preferences | Shell, add the following line to the automatically-run code in the black box:
import site
site.main()