I keep getting the following error, when using tensorflow in PyCharm:
/home/user/tensorflow/bin/python /home/user/PycharmProjects /TensorPlay/hello.py
Traceback (most recent call last):
File "/home/user/PycharmProjects/TensorPlay/hello.py", line 2, in <module>
import tensorflow as tf
File "/home/user/tensorflow/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/user/tensorflow/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 27, in <module>
import ctypes
File "/usr/lib/python3.5/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: /home/user/tensorflow/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _PyUnicode_AsWideCharString
Process finished with exit code 1
hello.py is this simple example code:
import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0)
print(node1, node2)
PyCharm detects all the Tensorflow elements and autocomplete everything i want to.
I also tried to run the virtualenv in the console.
Any Python related leads to the same error. I tried to upgrade tensorflow with
source ~/tensorflow/bin/activate
pip3 install --upgrade tensorflow
and had the exact same error too (Just instead of hello.py there was an error in file pip3)
Any suggestions?
EDIT:
I guess I see the problem. Might it be that my virtualenv wants Python 3.5.3? I thing with the last upgrade my Linux upgraded to Python 3.5.4 How can I fix it without creating a new virtualenv? And how I can make sure it doesn't happen on future updates?
I could only fix the issue with deleting the old virtualenv and setting up a new one.
Related
The thing is that when updating anaconda, the program made in Python no longer starts, then I leave the error.
The procedure that I have followed has been to make a copy of the Anaconda3 folder that I had installed, delete the Anaconda3 folder, install the new Anaconda3.
From the previous copy I took the Lib from the previous Anaconda3 and pasted it into the new one, and this is the error that appears.
Error:
D:\Anaconda3\lib\site-packages\numpy\__init__.py:143: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "D:\xampp\htdocs\RackManagement\app.py", line 3, in <module>
from apps.GT01.gt01 import app_gt01
File "D:\xampp\htdocs\RackManagement\apps\GT01\gt01.py", line 2, in <module>
from modules.db import getCodigos
File "D:\xampp\htdocs\RackManagement\modules\__init__.py", line 1, in <module>
from .tagColor import matchColor
File "D:\xampp\htdocs\RackManagement\modules\tagColor.py", line 1, in <module>
import cv2
File "D:\Anaconda3\lib\cv2\__init__.py", line 8, in <module>
from .cv2 import *
ImportError: numpy.core.multiarray failed to import
Well, I know that one of the ways to fix this would be to do a pip install or download the packages from anaconda, but on the server where this application is, it does not have access to the internet) that is, it is behind a firewall which only allows access to the application, that is to say for the server there is no internet and you cannot connect to download it.
As I have already said, the tests I did was to copy the folders from the old installation to the new one, but it still does not work
I'm trying to create my own torch dataset class and I ran into this problem
Traceback (most recent call last):
File "us_name_train.py", line 10, in <module>
from dataloader.usname_dl import NameDataset
File "C:\ProgramData\Anaconda3\lib\site-packages\dataloader\__init__.py", line 1, in <module>
from dataloader import read_data_sets
ImportError: cannot import name 'read_data_sets' from 'dataloader' (C:\ProgramData\Anaconda3\lib\site-packages\dataloader\__init__.py)
I've seen people post about this problem, but I think mine is extra odd, because the solution is to change 'dataloader' to 'DataLoader' cause it's a typo that was supposedly fixed in 2018, but my file is actually called 'dataloader.py' in the torch library and when I look through the file I do see the 'read_data_sets' function.
Also when I do change 'import dataloader' to 'import DataLoader' it says it can't find the module, but with 'import dataloader' it finds the module just can't find the function 'read_data_sets.' Other people had this problem cause they created their own module called dataloader, but I definitely don't have anything named 'dataloader' in my project dir. Anyone else deal with this issue?
I solved it by updating pytorch using
pip install --upgrade torch torchvision
I was on a robot class so i need both opencv and tensorflow, so i dowloaded both of them on window 10 64-bit. this is my code:
import cv2
import numpy as np
import tensorflow
#code here
which return this trace back:
Traceback (most recent call last):
File "C:/Users/Dell/PycharmProjects/SignClassifer/.idea/source_code.py", line 3, in <module>
import tensorflow
File "C:\Users\Dell\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
ImportError: No module named 'tensorflow.python'
Process finished with exit code 1
i was following those steps for downloading tensorflow with GPU for python on window. The "native" pip way: running this command:
C:\> pip3 install --upgrade tensorflow-gpu
It downloaded and installed fine. But when i try to import tensorflow this error happened, in an attempt to fix this error i also downloaded a tensorflow GPU packet with pycharm, doesnt seem to be any better, i ve looking all over the internet, doesnt seem to find anything.
I am simply following the tutorials of tensorflow and while performing following cmd :
python ptb_word_lm.py --data_path=/home/priyankit/data/validsrc2-hi --
model=small
It is showing following error:
Traceback (most recent call last):
File "ptb_word_lm.py", line 68, in
import util
File "/home/priyankit/models-master/tutorials/rnn/ptb/util.py", line
23, in
from tensorflow.core.protobuf import rewriter_config_pb2
ImportError: cannot import name rewriter_config_pb2
link to the repository
You need to do two things. First, upgrade tensorflow by doing:
pip install --upgrade tensorflow
Second, if you are not using a GPU, then execute the script with 0 GPUs as follows:
python ptb_word_lm.py --data_path=/home/priyankit/data/validsrc2-hi --model=small --num_gpus=0
I had exactly the same error loop when I tried doing the RNN Tensorflow tutorial on their website.
What worked for me (I don't have a GPU) was including this at the end "--num_gpus=0" when running my program on the terminal.
When I try to import the slycot module in spyder (version 2.2), I get the following error:
RuntimeError: module compiled against API version 7 but this version of numpy is 6
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/slycot/__init__.py",
line 4, in <module>
from slycot.analysis import ab01nd,ab05md,ab05nd,ab07nd,ab08nd, ab09ad
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/slycot/analysis.py",
line 21, in <module>
from slycot import _wrapper
ImportError: numpy.core.multiarray failed to import
Now, when I import slycot in the python shell through my terminal, there are no problems at all. I think the reason why there are no problems through the terminal, is that I recently installed numpy 1.7.1. Spyder on the other hand still uses numpy 1.6.2.,hence the error.
I tried to change the numpy version in spyder, but so far that didn't work.
When I change the numpy(6) folder in my spyder lib with the recently installed numpy(7), I get the following error (in spyder):
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python intepreter from there.
What is the best way to solve this error?
Thanks in advance.
(Spyder dev here) At the moment it's not possible for the user to install anything inside the app. I guess you moved your slycot module from another interpreter to our App (because of the numpy error you mention).
The right way to use different modules not present in the app, is to change the path of your interpreter in:
Tools > Preferences > Console > Advanced settings > Python executable
If you installed slycot using your system Python, you have to select
/usr/bin/python