I followed the instructions at:
http://joern.readthedocs.io/en/latest/installation.html
to install joern, and then the following to test Joern:
http://joern.readthedocs.io/en/latest/access.html
And got this error (using ipython):
import joern.all
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-903145a12480> in <module>()
----> 1 import joern.all
/home/xxxx/Downloads/python-joern-0.3.1/joern/all.py in <module>()
1 from py2neo import Graph
----> 2 from py2neo.ext.gremlin import Gremlin
3 import os
4
5 DEFAULT_GRAPHDB_URL = "http://localhost:7474/db/data/"
ImportError: No module named gremlin
Can someone teach me how to install "Gremlin"?
I did the following and it is still not working:
## wget -O neo4j-gremlin.zip http://mlsec.org/joern/lib/neo4j-gremlin-plugin-2.1-SNAPSHOT-server-plugin.zip
sudo mkdir -p /usr/share/neo4j/plugins/gremlin-plugin
sudo unzip neo4j-gremlin.zip -d /usr/share/neo4j/plugins/gremlin-plugin
and the "0.1.tar.gz" have installed the py2neo-gremlin-0.1 as well.
And "pip install Gremlin" does not worked too.
Now I have run out of idea.
You most likely have a version of py2neo installed that is incompatible with Joern. If you used pip to install py2neo, you will get v3.x but Joern appears to only support v2.0 at the moment. Run the following command to confirm:
python -c "import py2neo; print py2neo.__version__"
If the above does not print 2.0, remove py2neo by running pip uninstall py2neo and then install v2.0 specifically by running pip install py2neo==2.0. Then re-test by running python -c "from py2neo.ext.gremlin import Gremlin" - it should complete without errors.
Related
I am trying to install stable-baselines and run the first two lines from Getting Started section of the online manual but no option is working. I started with
pip install stable-baselines
Now when I run:
import gym
from stable_baselines.common.policies import MlpPolicy
I get
No module named 'tensorflow.contrib'
This apparently is because tensorflow version 2 doesn't have tensorflow.contrib. But version 2 was released in Sept 2019. Do I really have to use only tensorflow version 1?
What is the right way to install stable-baselines and run that simple example?
I tried
pip install stable-baselines3
in a virtual environment. This gives a different error:
In [2]: from stable_baselines.common.policies import MlpPolicy
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Input In [2], in <module>
----> 1 from stable_baselines.common.policies import MlpPolicy
ModuleNotFoundError: No module named 'stable_baselines'
In [3]: from stable_baselines3.common.policies import MlpPolicy
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Input In [3], in <module>
----> 1 from stable_baselines3.common.policies import MlpPolicy
ImportError: cannot import name 'MlpPolicy' from 'stable_baselines3.common.policies' (/home/raph/RL/stable-baselines/venv/lib/python3.8/site-packages/stable_baselines3/common/policies.py)
To quote the github readme:
Note: Stable-Baselines supports Tensorflow versions from 1.8.0 to 1.14.0. Support for Tensorflow 2 API is planned.
The same github readme also recommends to use stable-baselines3, as stable-baselines is currently only being maintained and its functionality is not extended. Thus, I would not expect the TF1 -> TF2 update any time soon.
If you can not install this version of tensorflow, I suggest to use stable-baselines3 and follow the examples. The code you posted above is not consistent with the stable-baselines3 docs, which import the MlpPolicy as
from stable_baselines3.sac.policies import MlpPolicy
According to the stable-baselines documentation you can only use Tensorflow version 1.8.0 to version 1.15.0.
If you want to run Tensorflow 1, and you want to use pip as your package manager, you'll need to install python version 3.7 or lower. I did the following in my ubuntu terminal
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.7
sudo apt install virtualenv
virtualenv --python=/usr/bin/python3.7 <env-name>
source <env-name>/bin/activate
pip install tensorflow==1.15.0
...
Alternatively, you could try using this guide, which gives instructions as to how to migrate something to Tensorflow version 2.
In the past I have installed the pymeep package in Google Colab with the following cell:
!wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
!chmod +x Miniconda3-latest-Linux-x86_64.sh
!bash ./Miniconda3-latest-Linux-x86_64.sh -b -p ./anaconda
import os
os.environ['PATH'] += ":/content/anaconda/bin"
!conda create -n mp -c conda-forge pymeep
import sys
sys.path.append('/content/anaconda/envs/mp/lib/python3.7/site-packages/')
Which is an exact copy from this website: https://rf5.github.io/2019/12/22/meep-intro.html
Sometimes the code I wrote doesn't work. It executes without errors, but when I try to execute import meep as mp. I get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-f30f3b609667> in <module>()
----> 1 import meep
ModuleNotFoundError: No module named 'meep'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Is there a better way of installing meep or rather pymeep in Google Colab?
Replace 3.7 with 3.8 as the latest python version installed using conda is 3.8
sys.path.append('/content/anaconda/envs/mp/lib/python3.8/site-packages/')
Example
Background: I'm currently running Elementary OS Hera(Ubuntu 18.04 LTS). The distribution came with Python 3.6.9. At some point I installed Python 3.7.5...this is when the issue(s) started.
Problem: I'm attempting to install PyQt5 which keeps defaulting to the older version for some reason. I ensured that Python3 was referencing the newer version:
Wick:~$ python3 --version
Python 3.7.5
I also ensured that python3.7 was the primary version:
Wick:~$ sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.7 2 auto mode
1 /usr/bin/python3.6 1 manual mode
* 2 /usr/bin/python3.7 2 manual mode
BUT when I run sudo apt-get install -y python3-pyqt5 . It still continues to install to the 3.6 version. This can be verified via:
:~$ python3 -c "from PyQt5.QtCore import QSettings; print('done')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.QtCore'
AND the kicker
:~$ python3.6 -c "from PyQt5.QtCore import QSettings; print('done')"
done
OR
:~$ python3.7 -c "from PyQt5.QtCore import QSettings; print('done')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.QtCore'
Any assistance you can offer is greatly appreciated. I'm losing my mind.
p.s. apologies in advance for being a newbie
The package only depends on python3.6: https://packages.ubuntu.com/bionic/python3-pyqt5. It will be installed because it is a prerequisite.
This was resolved by #chepner:
"I would recommend using a virtual environment created with /usr/bin/python3.7, >then install pyqt5 there using pip rather than trying to install it via your >package manager."
Thanks so much!
I am trying to install Pytorch via pip on ubuntu 18.04.I have python 3.6 and my laptop is HP-Pavilion notebook 15
The installation seems to be right because i get the message:
Installing collected packages: torch, torchvision Successfully
installed torch-1.3.1+cpu torchvision-0.4.2+cpu
i run the verification code and it is ok
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
However, when i close the terminal or reboot and try to run he same code i get the error:
Traceback (most recent call last):
File "torch.py", line 2, in
import torch
AttributeError: module 'torch' has no attribute 'rand'
How are you executing the python script? Which python are you using? Maybe you installed the package in a different python version?
Try to set alias to the python you want to use:
alias python=/usr/local/bin/python3.6
Then pip install the package with that python alias you will always be using.
python pip install <package name>
Python now will install the package in the python files with the alias python - heading to files: /usr/local/bin/python3.6
Let me know if the error still occurs!
Install pytorch using pip through the below command:
pip3 install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
for any reference go through the official website of pytorch.
Change your file .py to another name, you named torch.py when you import torch it will call ur torch.py
Im trying to install and use stats_exporter from opencensus.ext.stackdriver using the following guide: opencensus-ext-stackdriver
after installing it through pip:
pip install opencensus-ext-stackdriver
Im trying to import it and:
from opencensus.ext.stackdriver import stats_exporter as stackdriver
ImportError: cannot import name 'stats_exporter' from 'opencensus.ext.stackdriver'
When comparing the Git repo, and my local venv/lib/python3.7/site-packages/... it seems like the pip version isn't compatible with Github , so i tried to install it though cloning, and using setup.py
pip install ../opencensus-python/contrib/opencensus-ext-stackdriver/dist/opencensus-ext-stackdriver-0.2.dev0.tar.gz
which gives me the following error:
(venv) Yehoshaphats-MacBook-Pro:present-value yehoshaphatschellekens$ pip install ../opencensus-python/contrib/opencensus-ext-stackdriver/dist/opencensus-ext-stackdriver-0.2.dev0.tar.gz
Processing /Users/yehoshaphatschellekens/opencensus-python/contrib/opencensus-ext-stackdriver/dist/opencensus-ext-stackdriver-0.2.dev0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/s2/y6vcdc1105s8xlpb12slr9z00000gn/T/pip-req-build-7m1ibdpd/setup.py", line 17, in <module>
from version import __version__
ModuleNotFoundError: No module named 'version'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/s2/y6vcdc1105s8xlpb12slr9z00000gn/T/pip-req-build-7m1ibdpd/
Similar errors of this type indicated that i need to upgrade setuptools, tried that also :(
This post suggests that it might related to the fact that i'm using python3, which isn't completable with version though i really need to install this package on my python3 venv.
Any Help on this issue would be great!
Try this:
#!/usr/bin/env python
import os
from opencensus.common.transports.async_ import AsyncTransport
from opencensus.ext.stackdriver import trace_exporter as stackdriver_exporter
from opencensus.trace import tracer as tracer_module
from opencensus.stats import stats as stats_module
def main():
sde = stackdriver_exporter.StackdriverExporter(
project_id=os.environ.get("PROJECT_ID"),
transport=AsyncTransport)
tracer = tracer_module.Tracer(exporter=sde)
with tracer.span(name='doingWork') as span:
for i in range(10):
continue
if __name__ == "__main__":
main()
and
grpcio==1.19.0
opencensus==0.3.1
opencensus-ext-stackdriver==0.1.1
NB The OpenCensus libraries need gRPC too.
You will need:
a GCP Project and it's Project ID (${PROJECT_ID})
a service account with roles/cloudtrace.agent and its key.
Then:
virtualenv venv
source venv/bin/activate
export PROJECT_ID=[[YOUR-PROJECT-ID]]
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/key.json
pip3 install --requirement requirements.txt
python3 stackdriver.py