1

Recently I installed tensorflow (CPU) on my machine. Later, I decided to go for the GPU version by installing tensorflow-gpu. So I uninstalled the non-gpu version first and installed the gpu one following the steps on the tensorflow official site.

The problem is that when I try to use the framework I get this error

AttributeError: module 'tensorflow' has no attribute 'constant'

...after executing the following code in the interpreter:

>>> import tensorflow as tf
>>> tf.constant('a')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute 'constant'
>>>

Any ideas why that could've happened?

Note: I tried to uninstall tensorflow-gpu (in order to install it again) but I get this exception:

Exception:
Traceback (most recent call last):
File "c:\users\georgi koemdzhiv\appdata\local\programs\python\python3 \lib\shutil.py", line 544, in move os.rename(src, real_dst)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'c:\\users\\georgi koemdzhiv\\appdata\\local\\programs\\python\\python36\\lib\\site-packages\\tensorflow\\contrib\\tensor_forest\\hybrid\\python\\models\\__pycache__\\stochastic_hard_decisions_to_data_then_nn.cpython-36.pyc' -> 'C:\\Users\\GEORGI~1\\AppData\\Local\\Temp\\pip-uninstall-tdr0yqcp\\users\\georgi koemdzhiv\\appdata\\local\\programs\\python\\python36\\lib\\site-packages\\tensorflow\\contrib\\tensor_forest\\hybrid\\python\\models\\__pycache__\\stochastic_hard_decisions_to_data_then_nn.cpython-36.pyc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\georgi koemdzhiv\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\basecommand.py", line 228, in main
status = self.run(options, args)
File "c:\users\georgi koemdzhiv\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\commands\uninstall.py", line 68, in run
auto_confirm=options.yes, verbose=self.verbosity > 0,
File "c:\users\georgi koemdzhiv\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\req\req_install.py", line 661, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "c:\users\georgi koemdzhiv\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\req\req_uninstall.py", line 219, in remove
renames(path, new_path)
File "c:\users\georgi koemdzhiv\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\utils\misc.py", line 273, in renames
shutil.move(old, new)
File "c:\users\georgi koemdzhiv\appdata\local\programs\python\python36\lib\shutil.py", line 558, in move
copy_function(src, real_dst)
File "c:\users\georgi koemdzhiv\appdata\local\programs\python\python36\lib\shutil.py", line 257, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "c:\users\georgi koemdzhiv\appdata\local\programs\python\python36\lib\shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\GEORGI~1\\AppData\\Local\\Temp\\pip-uninstall-tdr0yqcp\\users\\georgi koemdzhiv\\appdata\\local\\programs\\python\\python36\\lib\\site-packages\\tensorflow\\contrib\\tensor_forest\\hybrid\\python\\models\\__pycache__\\stochastic_hard_decisions_to_data_then_nn.cpython-36.pyc'
Georgi Koemdzhiev
  • 11,421
  • 18
  • 62
  • 126
  • 1
    Please replace your image with a formatted error trace. That will be clearer. – Mohan Radhakrishnan Jul 02 '18 at 07:01
  • @MohanRadhakrishnan sorry about that. Will do that when I get home from work. – Georgi Koemdzhiev Jul 02 '18 at 07:03
  • 1
    Looks to me like an installation problem. Have you tried [reinstalling the package](https://stackoverflow.com/questions/19548957/can-i-force-pip-to-reinstall-the-current-version)? – jdehesa Jul 02 '18 at 11:56
  • @jdehesa I have not tried that yet. Will try as soon as I get home. Thanks! – Georgi Koemdzhiev Jul 02 '18 at 12:25
  • @MohanRadhakrishnan that's the picture replaced with console output. Sorry about the delay. – Georgi Koemdzhiev Jul 02 '18 at 16:55
  • @jdehesa unfortunately, the suggestion did not work. I ended up installing Anaconda and installing tensorflow-gpu. Now everything works. – Georgi Koemdzhiev Jul 02 '18 at 19:25
  • 1
    Hi Georgi. I'm an editor here, and I notice that a number of your questions have one or more "home-made tags" in the title, using square brackets. We'd [rather you didn't do that](https://meta.stackoverflow.com/a/253076/472495), since that is the purpose of the tagging system proper. Please write titles in ordinary English, either as a question, or a succinct summary of the issue. Thanks! – halfer Jul 07 '18 at 10:39
  • 1
    @halfer Thank you for the suggestion. You are right. Will make the appropriate amendments. – Georgi Koemdzhiev Jul 07 '18 at 10:40
  • 1
    Damn, I'm having the exact same error. I can't jus tinstall with anaconda or something because it's a custom whl for tensorflow with avx2 – Brent Rittenhouse Oct 18 '18 at 20:50
  • @BrentRittenhouse Unfortunately, I cannot be of help as I stopped digging for solutions as soon as I resolved my problem :/ – Georgi Koemdzhiev Oct 18 '18 at 21:19

0 Answers0